Sheet Metal Extents

Sheet Metal Extents

Anonymous
Not applicable
11,929 Views
87 Replies
Message 1 of 88

Sheet Metal Extents

Anonymous
Not applicable
I cannot understand why Autodesk does not have the sheet metal extents and
sheet metal style as parameters so we do not have to resort to VBA or
addins. (I know of the great program Yippee etc.)

Anyways, I have included the code from someone at Autodesk for the length
and width. What I do not understand is where to put this code so that it
will be updated every time the sheet metal part is changed. Is there a way
to do this? Do I place it in my sheet metal template file? I am a little
unclear as to where I put it. Also does somebody have the code for the
style?

(I know how to put it in the template file and run the macro but it does not
update unless this is done.)

It has been a while since I have done any programming in VB and have never
done any inside Inventor so any help on this would be greatly appreciated!.

**************************************************************
Public Sub extents_to_custom_props()
Dim objpartDoc As PartDocument

Set objpartDoc = ThisApplication.ActiveDocument

Dim objCompDef As SheetMetalComponentDefinition

Set objCompDef = objpartDoc.ComponentDefinition

Dim fpBox As Variant

Set fpBox = objCompDef.FlatPattern.Body.RangeBox

Dim width As Double

Dim length As Double


length = fpBox.MaxPoint.X - fpBox.MinPoint.X

width = fpBox.MaxPoint.Y - fpBox.MinPoint.Y


Dim objUOM As UnitsOfMeasure

Set objUOM = objpartDoc.UnitsOfMeasure


Dim strLength As String

Dim strWidth As String


strLength = objUOM.GetStringFromValue(length,
UnitsTypeEnum.kDefaultDisplayLengthUnits)

strWidth = objUOM.GetStringFromValue(width,
UnitsTypeEnum.kDefaultDisplayLengthUnits)


Call MsgBox("Width = " + strWidth + vbCrLf + "Length = " + strLength,
vbOKOnly, "Sheet Metal Flat Pattern")


Call Create_ext_prop("width", strWidth)

Call Create_ext_prop("length", strLength)



End Sub




Sub Create_ext_prop(prop As String, prop_value As String)


Dim opropsets As PropertySets

Dim opropset As PropertySet

Dim oUserPropertySet As PropertySet


Set opropsets = ThisApplication.ActiveDocument.PropertySets


For Each opropset In opropsets

If opropset.Name = "Inventor User Defined Properties" Then Set
oUserPropertySet = opropset

Next opropset


' If Property does not exist then add the new Property

On Error Resume Next

Call oUserPropertySet.Add(prop_value, prop)

' Try to set the Property value if it already exists


For i = 1 To oUserPropertySet.Count

If oUserPropertySet.Item(i).Name = prop Then
oUserPropertySet.Item(i).Value = prop_value

Next i


End Sub

*******************************************************************************


--
Rob
Inventor 11 SP2 Build 344a
Vault 5.0 Build 11.1.145.0


--
Rob
Inventor 11 SP2 Build 344a
Vault 5.0 Build 11.1.145.0
0 Likes
11,930 Views
87 Replies
Replies (87)
Message 81 of 88

karthur1
Mentor
Mentor

WHY does it not work? Do you get an error?  Can you post a screen shot of what you are seeing?

0 Likes
Message 82 of 88

skyngu
Collaborator
Collaborator

the addin works fine in inventor 2014 64bit.

Autodesk Inventor Professional 2027
0 Likes
Message 83 of 88

eric
Participant
Participant

It would register in the add-ins, but wouldn't actually update the parameter values. However, I messed around with ilogic and actually got a very simple two lines of code to do what I needed. Thanks for the reply.

0 Likes
Message 84 of 88

mslosar
Advisor
Advisor
Sorry to necro-post but you may want to post this version to the blog entry. I believe it still has the older version that doesn't always work for people. I couldn't get it work at all. Then I found this thread, and ran this setup just once and voila' - all's well 🙂
0 Likes
Message 85 of 88

karthur1
Mentor
Mentor

@ekinsb wrote:

Sorry for the delay in responding.  I have found a problem.  Attached is a new installer.  It will install the add-in along with a zip file that contains the source code.  Let me know if there are any problems running it.


 

I have upgraded from 2013 to 2015.  This was working in 2013... but now it does not update the parameters.  I ran the installer (the one posted in message 77 above) and it still does not work.  Before running the installer, I removed the files from the %appdata% folder, then ran the installer.

 

After I ran the installer, I did check the %appdata%\Autodesk\ApplicationPlugins\SheetMetalExtents folder and the .addin and the .dll is there... and the addin appears in the Inventor Add-ins manager (is also loaded).  It just does not write the values in the paramaters when I save my sheetmetal part.

 

Any suggestions from anyone using 2015 on getting this to work?

 

Thanks,

Kirk

0 Likes
Message 86 of 88

JohnKHouston
Advocate
Advocate
Try copying the installer to your local drive and install it from there. I had installed the app from a server drive and had the same problem as you but once I ran the installer from the local drive it updated correctly.

HTH
0 Likes
Message 87 of 88

karthur1
Mentor
Mentor

I ran it my c:\Temp folder.

 

Kirk

0 Likes
Message 88 of 88

Anonymous
Not applicable

The code works great for new sheet metal parts, but I cannot get it generate the data for existing parts. How is this done?

 

Thanks.

0 Likes