Inventor Customization

Inventor Customization

Active Contributor
Posts: 28
Registered: ‎12-05-2003
Message 1 of 1 (38 Views)

Sheet metal extents, again.

38 Views, 0 Replies
11-19-2003 02:58 AM
I found the code below in a search of the postings. The message stated that it was for Inventor 6. How do I get it to work in Inventor 7? I get the error "Object doesn't support this property or method", then it highlights line 2.

Public Sub AutoSave()
Dim oFlatPattern As FlatPattern
Set oFlatPattern = ThisDocument.ComponentDefinition.ReferenceComponents.FlatPattern

' Check to see if the flat exists.
If Not oFlatPattern Is Nothing Then
' Get the extent of the face.
Dim oExtent As Box
Set oExtent = oFlatPattern.Body.RangeBox

' Extract the width and length from the range.
Dim dLength As Double
Dim dWidth As Double
dLength = oExtent.MaxPoint.X - oExtent.MinPoint.X
dWidth = oExtent.MaxPoint.Y - oExtent.MinPoint.Y

' Convert these values into the document units.
' This will result in strings that are identical
' to the strings shown in the Extent dialog.
Dim oUOM As UnitsOfMeasure
Set oUOM = ThisDocument.UnitsOfMeasure
Dim strWidth As String
Dim strLength As String
strWidth = oUOM.GetStringFromValue(dWidth, kDefaultDisplayLengthUnits)
strLength = oUOM.GetStringFromValue(dLength, kDefaultDisplayLengthUnits)

' Write these string as custom properties. If the properties
' already exist, then just update them.
Dim oCustomPropSet As PropertySet
Set oCustomPropSet = ThisDocument.PropertySets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

On Error Resume Next
oCustomPropSet.Item("SheetMetal Width").Value = strWidth
If Err Then
Call oCustomPropSet.Add(strWidth, "SheetMetal Width")
End If

oCustomPropSet.Item("SheetMetal Length").Value = strLength
If Err Then
Call oCustomPropSet.Add(strLength, "SheetMetal Length")
End If
' The flat doesn't exist so delete the properties, if they exist.
On Error Resume Next
Set oCustomPropSet = ThisDocument.PropertySets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
oCustomPropSet.Item("SheetMetal Width").Delete
oCustomPropSet.Item("SheetMetal Length").Delete
End If
End Sub
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.