Python output - Civil object to Subassembly Object

I have a python script that gets all Subassemblies in the Maingroup and Offsetgroups.

Part of the list:
image
and
image

Problem is how to get the right output?
Each subassembly has a handle (by subassembly.Handle), but the line below doesn’t work.
ssel = SelectionByQuery.GetObjectByObjectHandle(str(subassembly.Handle))

If i create i list of Handles and use the node “DocumentExtensions.ObjectByHandle” then i’m getting:
image
But the node “Subassembly.Parameters” only accepts a subassembly object.
image

How to solve this?

looks the same as in:

No solution in this thread.

The SelectionByQuery class won’t work because subassemblies aren’t implemented with the OOTB nodes. And then with the Toolkit, is there a public constructor? Or have you tried casting?

I don’t know how to cast an civil object to dynamo in python. Can you provide me with an example. In python / C# or vb .net? I think it is used it in the node “Assembly.GetGroups” and many others.

Sorry, I misread your initial post. A cast isn’t the right thing to do here since you’re trying to go from a base class to a derived class, not the other way around.

The Civil 3D Toolkit doesn’t have a public constructor for the Subassembly class, but you could use the GetSubassembliesByName method to get around that. Something like this:

CorridorExtensions.Subassembly.GetSubassembliesByName(subAssem.Name)

where subAssem is the CivilObject.

Hi,
I can’t get it working. Below is the complete script and a sample file. The goal is to get a complete list of subassemblies (mainline assembly and offset assemblies). After that is can create all the parameter/values…

Attachment:
Cor_get_assemblygroups_v2.dyn (30.6 KB)
COR-Offset-Assembly.dwg (1018.2 KB)

Hi @mzjensen,

The GetSubassembliesByName returns all the Subassemblies in the model, but not per Assembly. I need to select the Subassembly per Assembly.

The goal is to extract the Featurelines and Parameters/Values from a Assembly with Offset Assemblies in it. The node in the Civil3D Toolkit doesn’t return the Offset Assemblies. See also the thread “Issue with Extract corridor feature lines - #7 by JPS”.

Hi @JPS,

If I understood correctly, you need a few parameters for every subassembly for all assemblies in your drawing. I don’t know if this works for you, but have you tried the following nodes?

Yes, i tried the nodes, but the node “Assembly.GetGroups” only reads the Mainline Assembly, not the offsets. see my other thread " Issue with Extract corridor feature lines".

I can’t seem to find a node to solve your problem in fact. However, if I were you I would try to use assemblies without the offsets groups. Instead, I would try to incorporate the offset subassemblies in the mainline assembly using using something like ConditionalHorizontalTarget or LinkOffsetAndElevation subassemblies if that makes sense. This way you could get access to all subassemblies parameters for all assemblies using Dynamo I guess.