I pieced this code together from different posts. It outputs the SM extents to two parameters named 'Length' and 'Width'. The parameters must exist already for the code to fire properly. It fires on save. Then you can format & export it to iProps. We do this because we have both Imperial & Metric units in our cut lists.
*
*
*
*
Public Sub AutoSave()
Dim oFlatPattern As FlatPattern
Set oFlatPattern = ThisDocument.ComponentDefinition.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
Dim dMaxX As Double
dMaxX = oExtent.MaxPoint.X
Dim dMinX As Double
dMinX = oExtent.MinPoint.X
dLength = dMaxX - dMinX
Dim dMaxY As Double
dMaxY = oExtent.MaxPoint.Y
Dim dMinY As Double
dMinY = oExtent.MinPoint.Y
dWidth = dMaxY - dMinY
'
Dim LengthParameter As Inventor.Parameter
Set LengthParameter = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.Item("Length")
LengthParameter.Value = dLength
'
Dim WidthParameter As Inventor.Parameter
Set WidthParameter = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.Item("Width")
WidthParameter.Value = dWidth
'
End If
'
End Sub
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<IOMATT> wrote in messageBrian,
href="news:6071087@discussion.autodesk.com">news:6071087@discussion.autodesk.com...
the addin works fine.
I have noticed that the addin puts the parameters in
whatever units the part is currently in, and they cannot be changed
afterwards. Also, when the part is updated, the affected ref parameter
'resets' itself, and I have to re-select export and re-format the value for it
to display properly. I'm not complaining, just stuff I noticed. I am very
grateful that you updated the addin, as are many other people I'm
sure.
Try running the addin installer one more time. I think this is the common error message that comes up and subsequently is fine. Also, I think there are many different versions floating around. I have attached aversion that I am using on 2009 that should also work fine on 2010. Try it instead of some of the others.
Rob
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
"KArthur1" wrote in messageI
href="news:6381923@discussion.autodesk.com">news:6381923@discussion.autodesk.com...
have used this on 2010 Xp machines but now I am trying to install it on a 2010
running Win7x64. When I run the install64.bat, I get the attached error. The
UAC is turned off and the user account is an administrator. I looked in
Inventor and the add-in is not loaded. I ran it a couple times and get the
same error.
Any ideas on what I can do to get this to
register?
Thanks
Kent,
I am only running the install file that they included. Where is the project properties you are refering to?
Kirk
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"
dir=ltr>
"KArthur1" wrote in message
href="news:6382650@discussion.autodesk.com">news:6382650@discussion.autodesk.com...
Kent,
I am only running the install file that they included. Where is
the project properties you are refering to?
Kirk
Kent,
It was posted in this thread by Brian Elkins. The one that I am using is the one that he posted on Nov, 14.
Kirk
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"
dir=ltr>
"KArthur1" wrote in message
href="news:6382854@discussion.autodesk.com">news:6382854@discussion.autodesk.com...
Kent,
It was posted in this thread by Brian Elkins. The one that I
am using is the one that he posted on Nov, 14.
Kirk