Message 1 of 17
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Darn, thought I had my goal completed...but then realized I created a new headache for myself. I have code for adding virtual parts on-the-fly to an assembly file based on existing parts...from @marcin_otręba
It works great....but I forgot that all my existing parts have a bunch of custom iProperties that allow our parts to flow into CADLink and then through to Netsuite ERP system.
Here's my code: I've commented a line about halfway down that shows what I need, highlighted in mageta:
On Error Resume Next Dim part_to_find As String = "Wedge" Dim part_to_place As String = "53500-024422" Dim description_to_place As String = "KNEE BRACING" Dim Custom_property_one As String = "Netsuite Description" Dim ass As AssemblyDocument = ThisDoc.Document Dim asscompdef As AssemblyComponentDefinition=ass.ComponentDefinition Dim occ As ComponentOccurrence For Each docFile In ass.AllReferencedDocuments If docFile.propertysets.item(5).item("Description").value.ToLower.Contains(part_to_find) Then Dim identity As Matrix identity = ThisApplication.TransientGeometry.CreateMatrix Dim virtOcc As ComponentOccurrence Dim qty As Integer = asscompdef.Occurrences.AllReferencedOccurrences(docFile).Count virtOcc = asscompdef.Occurrences.AddVirtual(part_to_place, identity) virtOcc.Definition.PropertySets.Item(3).Item("Part number").Value = part_to_place virtOcc.Definition.PropertySets.Item(3).Item("Description").Value = description_to_place '(How do I get the Custom Property Here?) .Value = Custom_property_one Dim bomm As Inventor.BOM = ass.ComponentDefinition.BOM bomm.StructuredViewEnabled = True Dim bomv As Inventor.BOMView = bomm.BOMViews.Item(2) For Each row As Inventor.BOMRow In bomv.BOMRows Dim oCompDef As Inventor.ComponentDefinition oCompDef = Row.ComponentDefinitions.Item(1) Dim oPartNumProperty As Inventor.Property If TypeOf oCompDef Is Inventor.VirtualComponentDefinition Then If oCompDef.PropertySets.Item(3).Item("Part Number").Value = part_to_place Then Row.TotalQuantity = 1*qty End If End If Next End If Next
So i learned how to add the standard properties like Description, but since the whole Custom thing is two levels, I can't figure it out. Can someone help me? Thanks in advance!
Solved! Go to Solution.