Hi All,
With the below Python code, I tried to replace a subassembly. But i doesn’t work as hoped. The code will replace the subassembly. But if the new subassembly has new parameters, Civil can’t handle this. I don’t why.
import clr
clr.AddReference('AcMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AeccDbMgd')
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
def replace_subassembly(subassembly,name,path):
errorReport = None
if not subassembly:
return
adoc = Application.DocumentManager.MdiActiveDocument
output = []
try:
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
oid = subassembly.InternalObjectId
aeccSubassembly = t.GetObject(oid, OpenMode.ForRead)
aeccSubassembly.UpgradeOpen()
dotnetObject = "Subassembly." + name
dotnetObjectpath = path
aeccGeneratorData = SubassemblyGenerator(SubassemblyGeometryGenerateMode.UseDotNet,dotnetObjectpath,dotnetObject)
aeccSubassembly.GeometryGenerator = aeccGeneratorData
aeccSubassembly.DowngradeOpen()
t.Commit()
#pass
except:
import traceback
errorReport = traceback. format_exc()
print("The process failed")
output.append("The process failed: " + errorReport)
return output
else:
print("errorReport: The process completed")
errorReport = "The process completed"
return errorReport
return errorReport
subassemblyObjs = IN[0]
newsubassemblyNETName = IN[1]
newsubassemblyFullpath = IN[2] # Full path to the .DLL
output = []
for subassembly in subassemblyObjs:
output.append(replace_subassembly(subassembly,newsubassemblyNETName,newsubassemblyFullpath))
OUT = output
See the new parameter “JNMirror”. I know that the 10 and 11 stands for Yes and No. In the “atttachpoint” (typo :)) holds an Enum list. They are now strings at not enum lists.
Can anybody explain this?