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

87 REPLIES 87
Reply
Message 1 of 88
Anonymous
2752 Views, 87 Replies

Sheet Metal Extents

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
87 REPLIES 87
Message 81 of 88
karthur1
in reply to: eric

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

Message 82 of 88
skyngu
in reply to: eric

the addin works fine in inventor 2014 64bit.

Autodesk Inventor Professional 2019
Message 83 of 88
eric
in reply to: karthur1

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.

Message 84 of 88
mslosar
in reply to: ekinsb

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 🙂
Message 85 of 88
karthur1
in reply to: ekinsb


@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

Message 86 of 88
JohnKHouston
in reply to: karthur1

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
Message 87 of 88
karthur1
in reply to: JohnKHouston

I ran it my c:\Temp folder.

 

Kirk

Message 88 of 88
s.mccarthy
in reply to: karthur1

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.

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

Post to forums  

Autodesk Design & Make Report