- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
THIS IS WHAT I HAVE SO FAR BUT ITS NOT WORKING:
' Rule to update flat extents parameters for sheet metal parts in an assembly
Dim flatExtentsLength As Double = SheetMetal.FlatExtentsLength * 2.54 ' Convert to inches
Dim flatExtentsWidth As Double = SheetMetal.FlatExtentsWidth * 2.54 ' Convert to inches
' Loop through all components in the active assembly
For Each comp As ComponentOccurrence In ThisApplication.ActiveDocument.ComponentDefinition.Occurrences
' Check if the component occurrence is a part document and a sheet metal part
If comp.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then
Dim partDoc As PartDocument = comp.Definition.Document
If partDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then ' Check if sheet metal part
' Get the parameters of the component definition
Dim params As Parameters = partDoc.ComponentDefinition.Parameters
' Check if parameters "DIMA" and "DIMB" exist, update or add them
If Not params.UserParameters.Item("DIMA").Exists Then
params.UserParameters.AddByValue("DIMA", flatExtentsLength, "in")
Else
params.UserParameters.Item("DIMA").Value = flatExtentsLength
End If
If Not params.UserParameters.Item("DIMB").Exists Then
params.UserParameters.AddByValue("DIMB", flatExtentsWidth, "in")
Else
params.UserParameters.Item("DIMB").Value = flatExtentsWidth
End If
' Set parameters to be exposed as properties
params.Item("DIMA").ExposedAsProperty = True
params.Item("DIMB").ExposedAsProperty = True
End If
End If
Next
' Update the active assembly after parameter changes
ThisApplication.ActiveDocument.Update