Is it possible to edit iProperties in suppressed parts?

Is it possible to edit iProperties in suppressed parts?

Lars_Greft
Advocate Advocate
704 Views
12 Replies
Message 1 of 13

Is it possible to edit iProperties in suppressed parts?

Lars_Greft
Advocate
Advocate

Hello, I want to edit the text of the property "Keywords" (within the Summary tab).  I use the code below in the assembly and if the part is suppressed it should get the text "Reference" and if it's not suppressed it should get the property "Normal". This will help us within Vault to see if the part is suppressed or not without opening the model.

 

I've tried the code, but noticed the text value is only written to the part if it's not suppressed. So I would like to know if it's possible to send a text value to a suppressed part, because now it will always have the text "Normal".

 

Dim ThisAssembly As AssemblyDocument = ThisDoc.Document
	
For Each ChildPart As ComponentOccurrence In ThisAssembly.ComponentDefinition.Occurrences
	If ChildPart.Suppressed Then
		iProperties.Value(ChildPart.Name, "Summary", "Keywords") = "Reference"
	Else
		iProperties.Value(ChildPart.Name, "Summary", "Keywords") = "Normal"
	End If
Next

InventorVb.DocumentUpdate()

 

Inventor 2021.3.1

0 Likes
705 Views
12 Replies
Replies (12)
Message 2 of 13

WCrihfield
Mentor
Mentor

Hi @Lars_Greft.  No, you can not do much at all with a suppressed assembly component, other than check the component's name.  If you need to read or write to the iProperties of the document which that component represents, you may have to access that document directly through the main assembly's ReferencedDocuments (top level document references only), or its AllReferencedDocuments (all document references from all levels of the assembly), instead of through the component.  To do so, you could loop through each oRefDoc As Document In ThisAssembly.AllReferencedDocuments, for example, then use the oRefDoc variable's properties to access its iProperties.

You can either get to its iProperties using API route:

oRefDoc.PropertySets.Item("Inventor Summary Information").Item("Keywords").Value

or extract the document's file name (without path, but with file extension) to use as the first input variable in the iProperties.Value(docName, setName, propname) method.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 13

Lars_Greft
Advocate
Advocate

Thank you the reply @WCrihfield, I've tried the code below but unfortunately that also doesn't work with suppressed components. I don't have enough knowledge with iLogic to extract the document's file name, is it possible for you to help me with that, by giving an example?

 

Dim ThisAssembly As AssemblyDocument = ThisDoc.Document

For Each oRefDoc As Document In ThisAssembly.ReferencedDocuments
	oRefDoc.PropertySets.Item("Inventor Summary Information").Item("Keywords").Value = "Test"
Next

InventorVb.DocumentUpdate()

 

0 Likes
Message 4 of 13

WCrihfield
Mentor
Mentor

Sure.  I see two things that may be causing problems.  The first thing is using that exact term 'ThisAssembly', which is already being used by iLogic in the background.  That is a term used to represent an iManagedAssembly object (Interface), so I would advise you to use a different term there for your variable name.  Next, I don't think the referenced document that you area writing the iProperty data to is getting updated or saved after the edit, so the edit may not be staying.  I modified your code a bit to help remedy these things.  Give this version a try.

Dim oADoc As AssemblyDocument = ThisDoc.Document
For Each oRefDoc As Document In oADoc.ReferencedDocuments
	If oRefDoc.PropertySets.Item("Inventor Summary Information").Item("Keywords").Value <> "Test" Then
		oRefDoc.PropertySets.Item("Inventor Summary Information").Item("Keywords").Value = "Test"
	End If
	If oRefDoc.RequiresUpdate Then oRefDoc.Update2(True)
	If oRefDoc.Dirty Then oRefDoc.Save2(False)
Next
oADoc.Update

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 13

Lars_Greft
Advocate
Advocate

Thank you for the help, unfortunately it doesn't work with suppressed components.

I placed the following code at line 4 (within the if statement) "MessageBox.Show(oRefDoc.DisplayName, "Title")" and noticed that only the unsuppressed components are being showed. So I guess the "ReferencedDocuments" only works with unsuppressed components and not with suppressed components.

 

I just came across this post by @JelteDeJong  and it says that you should look at occurrences. It also says the following "if you want to do something with suppressed documents the you will need to load them by opening them." The code in the post opens the suppressed parts, but doesn't close them. I need the code to work with automated models, so I can't manually close the files. Is there a way to also close the files after the change?

0 Likes
Message 6 of 13

JelteDeJong
Mentor
Mentor

In the case of that post, the main method would look like this. (with save and close)

 

Sub Main()
    Dim doc As AssemblyDocument = ThisDoc.Document

    Dim refDocNames As List(Of String) = getRefDocList(doc)

    For Each refDocName As String In refDocNames
        Dim refDoc As Document = getDocument(refDocName)

        ' Do the work on your document here
        MsgBox(refDoc.DisplayName)

        refDoc.Save() ' <--  look here
        refDoc.Close(True) ' <--  look here
    Next
End Sub

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 7 of 13

Lars_Greft
Advocate
Advocate

That works @JelteDeJong, thank you! The only thing now is that I need to write the text "Reference" to suppressed components and the text "Normal" to unsuppressed components.

Initially I used "If ChildPart.Suppressed Then", but that doesn't work anymore (makes sense). But how do I know if the current "refDoc" is suppressed or not?

0 Likes
Message 8 of 13

WCrihfield
Mentor
Mentor

Hi @Lars_Greft.  One thing that comes to mind when I see the two terms you are wanting to write to these documents is the BOMStructure property of the AssemblyComponentDefinition, PartComponentDefinition, ComponentDefinition, and the ComponentOccurrence objects, which uses the BOMStructureEnum variations as its value.  Many folks use that for setting whether the model is to be used for 'Normal' purposes, 'Reference', 'Purchased', 'Phantom', 'Inseperable', and such.  The BOM also uses that value when determining some things, so it can be very useful to take advantage of, if you are not already.  Manually, within a model type document, you can open the Document Settings (on the Tools tab > Options panel), and the 'Bill of Materials' tab within that dialog to set its value.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 9 of 13

Lars_Greft
Advocate
Advocate

Hey @WCrihfield, I do use the BOM structure for some things, but in this case it's not relevant. Instead of the text "Reference" and "Normal" I could also use "Suppressed" and "Unsuppressed". It's just that we need an indicator in Vault that tells us if the part is suppressed or not, without opening the model.

0 Likes
Message 10 of 13

wfajber
Contributor
Contributor

You have better experts than me chiming in, but I once tried to do something similar and can add my two cents. As you found out, Suppressed Components are suppressed from loading fully into memory. And if they are not fully loaded into memory, it seems fair that you cannot access the internals.

In my case, i gave up and changed the iLogic rule from manipulating suppressed components to identifying things with visible/invisible status. Visibility status in a view rep does ability to examine the iproperties and works great with part lists too.

Message 11 of 13

WCrihfield
Mentor
Mentor

Hi @wfajber.  Good point.  That's mainly what I have pretty much always done.  I knew that the 'level of detail' representations (before ModelStates) were originally created with performance issues in mind, because they primarily record which components in an assembly are suppressed, and suppressing components 'unloads' them from Inventor's session memory, which increases performance.  However, many over the years have adopted the use of suppressing components as a means of controlling BOM quantities.  After some initial dabbling/testing with that process, and finding out how restrictive their use was to many of my other processes, I have chosen since then to use 'design view representations', component visibility, and the BOMStructure to help control BOM/PartsList related issues, which has worked just fine for me.  However, our assembly BOM's are not directly exported/translated into any sort of ERP system (at this time), and we make more use of drawing PartsLists than we do of the assembly's BOM directly.  Plus we use a lot of automation tools, where others may not.  So I certainly do not fault or discourage any specific way of doing things, because there are a vast array of needs and scenarios out there that require all sorts of different solutions.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 12 of 13

WCrihfield
Mentor
Mentor

Hi @Lars_Greft.  I do not have Vault yet, though we have talked about it several times, and may be getting it soon.  I wander though what would happen in situations were your assembly may have multiple instances of components that represent the same source document, when 1 or more of them may be suppressed, and 1 or more of them may not be suppressed.  If you are writing one of those terms to the document, wouldn't that info be incorrect or misleading?  I don't know, just a thought that popped into my mind.  One fairly new thing that comes to mind is the 'instance properties', which allows you to set custom iProperty values to each instance of a component in an assembly, even if they represent the same base document.  But I don't know if Vault can work with those 'instance' properties, so I don't know if their use would help or not.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 13 of 13

Lars_Greft
Advocate
Advocate

Hey @WCrihfield, I did thought about that. But in our situation there is mostly only one instance of a component, and if there are multiple instances they are all suppressed or all instances are unsuppressed.

Instance properties sound interesting, but I just looked into it and it's introduced in Inventor 2022. We are using 2021.3.1 so that won't work for us. And here it says that instance properties aren't supported at this moment in Vault.