Custom Property Push from Parent Assembly to Sub Assembly

Custom Property Push from Parent Assembly to Sub Assembly

jigneshah25
Participant Participant
58 Views
0 Replies
Message 1 of 1

Custom Property Push from Parent Assembly to Sub Assembly

jigneshah25
Participant
Participant

I am trying to push the Custom properties from the Parent assembly to the Sub assembly.

Right now your logic calculates Model_X once at the top assembly and then just pushes that same value into every subassembly.

I want each subassembly to have its own Model_X (based on its own bounding box, not the parent’s), you’ll need to calculate the RangeBox inside the recursion instead of storing one fixed value in the dictionary.

Kindly Help. Thanks in Advance. 

 

Sub Main
Dim oAsm As AssemblyDocument
oAsm = ThisDoc.Document
 
Dim param_dict As New Dictionary(Of String, String)
 
'param_dict.Add("COUNTRY OF MANUFACTURING / ORIGIN – STEELWORK", iProperties.Value("PARAMETERS.ipt", "Custom", "COUNTRY OF MANUFACTURING / ORIGIN – STEELWORK"))
param_dict.Add("Model_X",Measure.ExtentsLength)
param_dict.Add("ipropertyName2", "value2")
 
custom_prop_set = oAsm.PropertySets.Item("Inventor User Defined Properties")
Dim oprop As Inventor.Property
For Each kvp As KeyValuePair(Of String, String) In param_dict
Try
oprop = custom_prop_set.Item(kvp.Key)
 
Catch
oprop = custom_prop_set.Add("", kvp.Key)
End Try
 
oprop.Value = kvp.Value
 
Dim oOcc As ComponentOccurrence
For Each oOcc In oAsm.ComponentDefinition.Occurrences
If Component.IsActive(oOcc.Name) = True
If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
Pass_custom_prop(oOcc,kvp.Key,kvp.Value)
End If
End If
Next
Next
End Sub
 
Sub Pass_custom_prop(oSubAsm As ComponentOccurrence,custom_property_name As String , custom_property_value As String)
Dim oSubDoc As Inventor.Document = oSubAsm.Definition.Document
Dim oSubCustPropSet As Inventor.PropertySet = oSubDoc.PropertySets.Item("Inventor User Defined Properties")
Try
oSubProp = oSubCustPropSet.Item(custom_property_name)
    
Catch
oSubProp = oSubCustPropSet.Add("", custom_property_name)
End Try
 
oSubProp.Value = custom_property_value
End Sub
0 Likes
59 Views
0 Replies
Replies (0)