Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sheet metal extents, again.

0 REPLIES 0
Reply
Message 1 of 1
pviellieux
133 Views, 0 Replies

Sheet metal extents, again.

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
Err.Clear
Call oCustomPropSet.Add(strWidth, "SheetMetal Width")
End If

oCustomPropSet.Item("SheetMetal Length").Value = strLength
If Err Then
Err.Clear
Call oCustomPropSet.Add(strLength, "SheetMetal Length")
End If
Else
' 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
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report