Civil 3D - Toolkit - Get subassembly .NET class and assembly name

Hi All,

In the Toolkit i can’t find a node for subassembly .NET class name and the .NET assembly name. How do i get it in Python? The goal is a script that will pack al the used subassemblies in a zip file.

image

I would suggest that you do not pack dll’s that are natively part of a application as you can end up in Dll hell(https://archi-lab.net/dll-hell-is-real/). You also then have to manage/update every one every time they are updated as well, so can become a management headache.

To add that dll to your package you will have to watch out that you have the applicable license from the creator to distribute that dll with your addon.

To get the assembly name you should be able to do something similar to this(Assembly.GetExecutingAssembly Method (System.Reflection) | Microsoft Docs) though converting it to python syntax.

@Brendan_Cassidy your answer about DLL Hell is spot-on, but it’s not quite applicable in this context. Civil 3D Assemblies and Subassemblies are essentially cross section elements that are the building blocks for creating corridor models.

Subassemblies are defined by a DLL, so the terminology gets confusing because a Subassembly has a corresponding .NET assembly that is used to generate it’s geometry and behavior.

Anyway, @JPS here’s a quick Python snip. The data you’re looking for is stored in the Subassembly’s GeometryGenerator class.

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 get_subassembly_info(subassembly):

	if not subassembly:
		return
	
	adoc = Application.DocumentManager.MdiActiveDocument
	output = []
	
	with adoc.LockDocument():
	    with adoc.Database as db:
	        with db.TransactionManager.StartTransaction() as t:
	            oid = subassembly.InternalObjectId
	            aeccSubassembly = t.GetObject(oid, OpenMode.ForRead)
	            aeccGenerator = aeccSubassembly.GeometryGenerator
	            output.append(aeccGenerator.MacroOrClassName)
	            output.append(aeccGenerator.ProjectOrAssemblyName)
	            t.Commit()
	            pass
	return output

OUT = get_subassembly_info(IN[0])
2 Likes

First Sorry for my very late response. Was to busy with projects.

Thanks, @zachri.jensen. This sent me in the right direction. Got it working now