Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Unable to obtain Transparent objects of a DesignViewRepresentation.

Anonymous

Unable to obtain Transparent objects of a DesignViewRepresentation.

Anonymous
Not applicable

Hi Experts,

 

Inventor 2017\2019 Professional

C#

Windows 10

 

I am using the Inventor API to iterate through an Assembly's design view representations and print out (debug print) all hidden parts and transparent parts. Obtaining the hidden parts is not a problem, however there is no way I could obtain the transparent parts as I do not see any API method\property.

 

Note: The design view does not have to be active. 

 

Thanks,

-Thilak Rao

0 Likes
Reply
590 Views
10 Replies
Replies (10)

DRoam
Mentor
Mentor

According to the API help page for ComponentOccurrence, there's a ComponentOccurrence.Transparent property, which was introduced in Inventor 2017. So you should be able to iterate through the assembly's occurrences and check the Transparent property.

0 Likes

Anonymous
Not applicable

Thank you for attempting to help.

As I mentioned earluier, I am iterating the design view representation and would like to obtain this information.

 

What you say is true, if I had to set the design view representation as active and then iterate the assembly, which I do not want to do so.

 

Thanks,

-Thilak Rao

0 Likes

DRoam
Mentor
Mentor

Sorry, you said, "The design view does not have to be active", not, "I don't want to set the design view as active".

 

If you don't want to activate the design view then I'm not sure. Interestingly, there's a "DesignViewInfo" property that returns an XML of the design view's properties, and oddly enough it contains information about which occurrences are set not-visible, but not which occurrences are set transparent. So that's strange.

 

I think activating the view and iterating through occurrences may be the only way. You could try setting ThisApplication.ScreenUpdating to False before iterating through views, to see if that speeds it up any. Just remember to set it back to True after your code ends.

 

Question, how are you getting the visible components without activating the design view? I don't even see a way to do that...

0 Likes

DRoam
Mentor
Mentor

Here's a script that does what I described. In my basic test it was pretty snappy (at least faster than if you didn't turn screen updating off). It also rolls all of the view rep changes into a single undo transaction and then aborts it. So rather than leaving an undo entry for every design view switch, it leaves no undo entries at all.

 

Still not ideal, but will hopefully work for you. I'm as curious as you if there's a way to query the view reps directly without activating them.

 

Dim oAssyDoc As AssemblyDocument = ThisDoc.Document
Dim oCompDef As AssemblyComponentDefinition = oAssyDoc.ComponentDefinition
Dim oRepMan As RepresentationsManager = oCompDef.RepresentationsManager

Dim oCurView As DesignViewRepresentation = oRepMan.ActiveDesignViewRepresentation

Dim oList As New List(Of String)

ThisApplication.ScreenUpdating = False
Dim oTransaction As Transaction = ThisApplication.TransactionManager.StartTransaction(oAssyDoc,"Check View Rep Transparency")
For Each oView As DesignViewRepresentation In oRepMan.DesignViewRepresentations
	oView.Activate
	
	For Each oOcc As ComponentOccurrence In oCompDef.Occurrences
		If oOcc.Transparent Then
			If Not oList.Contains("View: " & oView.Name) Then oList.Add("View: " & oView.Name)
			oList.Add(vbTab & oOcc.Name)
		End If
	Next
Next
oCurView.Activate
oTransaction.Abort
ThisApplication.ScreenUpdating = True

MessageBox.Show(String.Join(vbCrLf,oList))
0 Likes

Anonymous
Not applicable

Thanks again.

The DesignViewInfo has been this way for many releases. Inventor does definitely know as to which are Transparent but does not carry that information in DesignViewInfo.

 

You answered your own question :-).

>>Question, how are you getting the visible components without activating the design view?

 

Answer >>Interestingly, there's a "DesignViewInfo" property that returns an XML of the design view's properties, and oddly enough it contains information about which occurrences are set not-visible.

 

Thanks,

-Thilak Rao

0 Likes

DRoam
Mentor
Mentor

Haha, I wondered if maybe you were using that.

 

Do you use dedicated XML methods to query that data? If so, would you be willing to share the code you use to do so? I've been meaning to start experimenting with querying/writing to XML via VB, this would be a good example.

0 Likes

Anonymous
Not applicable

Attached is the class file that you can use. Remember to deserialize the input string using XmlSerializer and cast it to DesignViewInfo object.

 

-Thilak Rao

0 Likes

Anonymous
Not applicable

I thought DevTech was active here and expected a quick response.

0 Likes

JamieVJohnson2
Collaborator
Collaborator

If you are a member of the ADN (paid member), then the forums get an extra button, that you can push stating need answer.  That button opens a help ticket that gets the attention of Autodesk Development.  

Otherwise there are a few Autodesk employee's that monitor these posts for answers that are not getting a response or proper solution, but they are generally on a 'volunteer' to respond basis.

 

jvj
0 Likes

Anonymous
Not applicable

Adam nagy or ChandraShekar

Could you'll please have a look at this and confirm if there is a decent solution rather than iterate all views, set them active and iterate the entire assembly?

 

Thanks,

-Thilak Rao

0 Likes