Showing results for 
Search instead for 
Did you mean: 

Get Components from Assembly




I have a 2 question. First, how can I get the copmonents of my assembly? For example, I have DraftDocument. It has a drawing assembly. I need to get the name of assembly from draft document and get the components of this assembly. Is it possible to get without ModelLinks?


Second - how can I get the root assembly name if there are some assemblies in my model?


Re: Get Components from Assembly

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

One way of getting the name of the assembly from the draft document 'without using Model Links' would be to use the 'New > Create Drawing' command from the SE Application button when creating the Draft, place the view, then save the Draft with the default name which is same as that of the assembly. In the API, simply use the oDraftDoc.Name to get the assembly name.


Regarding your other question, I have seen this type of API in SW as below, where the root component is obtained from the active configuration:

swConf = oDocAssembly.GetActiveConfiguration
swRootComp = swConf.GetRootComponent


SE too has a configuration interface but similar method to obtain a root component is not seen.


Since the root component is the assembly name and cannot be renamed, the best way to get to it from an occurrence is to grab the Application object of the occurrence and get the file name of its active document.


Hope that helps.