How to pick(CommandManager.Pick) sub assembly then apply a custom iProperty

How to pick(CommandManager.Pick) sub assembly then apply a custom iProperty

Preston_Reed
Advocate Advocate
552 Views
2 Replies
Message 1 of 3

How to pick(CommandManager.Pick) sub assembly then apply a custom iProperty

Preston_Reed
Advocate
Advocate

Hello, I am trying to make a rule where the user is prompted to select a particular sub assembly then it will apply values to its iProperties.  My issue is that if I use the method of CommandManager.Pick then I don't know how to apply a custom iproperty using oOccurrence.  Then if I want to use my typical method for applying custom iproperties via documents I don't know how to make the Pick in terms of document type.  

 

So, is there a way to

a) apply custom iProperties through oOccurrence (Assembly to sub assembly/parts)

b) prompt a user to make a selection using document type

 

or if theres another way im all ears. 

 

 Selection Method

' Selection
	Dim oOccurence As Inventor.ComponentOccurrence = ThisApplication.CommandManager.Pick(Inventor.SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "select")
	Dim oAry As Array = Split(oOccurence.Name, ":")
	Dim oAsmDoc As Inventor.AssemblyDocument = ThisDoc.Document
	Dim oSlct As Inventor.SelectSet = oAsmDoc.SelectSet
	
	Dim oOccEnum As ComponentOccurrencesEnumerator = oAsmDoc.ComponentDefinition.Occurrences.AllReferencedOccurrences(oOccurence.Definition) 
	Dim oObjColl As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	For Each oOcc As ComponentOccurrence In oOccEnum
		oOcc.PropertySets("Inventor User Defined Properties").Item("S0Class").Value = "1"
	Next

 

Typically how I apply iprops to sub assemblies 

For Each oRefDoc As Document In oRefDocs
		' Skipping any purchased or mfg parts / any parts that are not accessable 
		If oRefDoc.IsModifiable() = True AndAlso oRefDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then	
			Dim oCustomPropertySet As PropertySet
			oCustomPropertySet = ThisApplication.ActiveDocument.PropertySets.Item("Inventor User Defined Properties")
			Dim oCustProp As Inventor.Property
		
			For Each oCustProp In oCustomPropertySet
				oRefDoc.PropertySets("Inventor User Defined Properties").Item("CUSTOMER NAME-1").Value = CUSTOMERNAME1
				oRefDoc.PropertySets("Inventor User Defined Properties").Item("CUSTOMER PO#").Value = CUSTOMERPO
				oRefDoc.PropertySets("Inventor User Defined Properties").Item("END USER-1").Value = ENDUSER1
			Next
		Else
			' Do Nothing
		End If 
	Next

 

0 Likes
Accepted solutions (1)
553 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor
Accepted solution

You could try something like this:

Dim occ As ComponentOccurrence = ThisApplication.CommandManager.Pick(
    SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select your sub assembly")

Dim refDoc As Document = occ.ReferencedDocumentDescriptor.ReferencedDocument
Dim propSet As PropertySet = refDoc.PropertySets.Item("Inventor User Defined Properties")

propSet.Item("CUSTOMER NAME-1").Value = CUSTOMERNAME1
propSet.Item("CUSTOMER PO#").Value = CUSTOMERPO
propSet.Item("END USER-1").Value = ENDUSER1

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 3 of 3

Preston_Reed
Advocate
Advocate

That worked perfectly, thank you very much 

0 Likes