11-15-2023
08:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-15-2023
08:32 AM
sorry, but whole code is messed up,
main error is in line 17 oObj not declared or set to any value.
also
iProperties.Value("part1:1", "Project", "Part Number")
"part1:1" - it is oOcc.name not oDoc.DisplayName - it will give error as well
this code should work for you:
Sub Main Dim oAssyDoc As AssemblyDocument = ThisApplication.ActiveDocument Dim oAssyDef As AssemblyComponentDefinition = oAssyDoc.ComponentDefinition Dim oDoc As Inventor.Document For Each oOcc As ComponentOccurrence In oAssyDef.Occurrences 'verify document type (we are interested in metal sheets only) If oOcc.Definition.Document.ComponentDefinition.Type = kSheetMetalComponentDefinitionObject Then Call cQM( oOcc.Definition.Document) End If Next End Sub Sub cQM( oDoc As PartDocument) Dim oDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition Dim sfr As Double = oDef.FlatPattern.Length * 10 * oDef.FlatPattern.Width * 10 Try oDoc.PropertySets.Item(4).Item("QTA_MATERIALE").Value = sfr Catch oDoc.PropertySets.Item(4).Add(sfr,"QTA_MATERIALE") End Try Try oDoc.PropertySets.Item(4).Item("DIMENSIONI").Value = "" Catch oDoc.PropertySets.Item(4).Add("","DIMENSIONI") End Try End Sub