Hi All,
First time posting here, so sorry if everything is not to standard.
At my job we typically do our design work in separate dwg files which we then XREF into a separate dwg file containing the sheet which will then be plotted. I can’t upload documents yet since I’m a new user unfortunately, but I will upload the dwgs as soon as I can.
I’m trying to make a dynamo program that labels the slope of all the feature lines in the XREF’d file and puts the labels in the model space of the sheet file. This is the same behavior as using the label command on a feature line in an XREF’d file.
So far I’ve been able to make a program which can label the feature lines in the XREF’d file using a custom python node (code below), but they don’t appear in model space, and are instead put into a glitchy state where they are contained inside the XREF (you need to regen the drawing after running the dyanmo script to see the glitchy labels).
Python Node Code:
import sys
import clrclr.AddReference(‘AcMgd’)
clr.AddReference(‘AcCoreMgd’)
clr.AddReference(‘AcDbMgd’)
clr.AddReference(‘AecBaseMgd’)
clr.AddReference(‘AecPropDataMgd’)
clr.AddReference(‘AeccDbMgd’)from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *from Autodesk.Civil.DynamoNodes import CivilObject
dataEnteringNode = IN
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editorwith adoc.LockDocument():
with adoc.Database as db: with db.TransactionManager.StartTransaction() as t: errorReport = None try: # Open block table for write bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite) btrID = bt.get_Item(BlockTableRecord.ModelSpace) btr = t.GetObject(btrID, OpenMode.ForWrite) xrefList = IN[0] for xref in xrefList: for item in xref: if isinstance(item, CivilObject): realObject = item.AcObject if isinstance(realObject, FeatureLine): featlineObjId = realObject.ObjectId segNum = int(realObject.EndParam) if segNum > 1: for i in range(segNum): featlineLabelObjId = GeneralSegmentLabel.Create(featlineObjId,0.5+i) else: parcelLabelObjID = GeneralSegmentLabel.Create(featlineObjId,0.5) except: import traceback errorReport = traceback.format_exc() t.Commit()
if errorReport == None:
OUT = ‘Program Ran Succesfully’else:
OUT = errorReport
And here’s a picture of the dynamo setup (Camber and Civil3DToolkit are my only extensions installed)