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
2784 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 21 of 88
Anonymous
in reply to: Anonymous

is there anyway that an area can be calculated from the extents values given by your program? i need something that i can put directly on a drawing.
Message 22 of 88
Anonymous
in reply to: Anonymous

Hi Brian,

It seems this functionality is now in Inventor 2009 by default. (Maybe it's even your code they used!) However, I have been trying to find any sort of info on how I can get access to the sheet metal length and width iProps from within a parameter equation.

Would it be a crazy task to take your code and instead of outputting to iProperties named SheetMetalLength, etc, you could output to similarly named part parameters?

We are soooo close to being able to create a description field in our parts such as PL 1/4" x 50 1/2" x 15 3/4" for example.

Thanks!
-KB
Message 23 of 88
Anonymous
in reply to: Anonymous


That should be an easy modifcation.  I don't
have time to look at it now, but if you do any programming I suspect you can
figure it out.  Otherwise raise the issue again when AU is over and I'll
try and take a look.
--
Brian Ekins
Autodesk Inventor API

href="http://blogs.autodesk.com/modthemachine">http://blogs.autodesk.com/modthemachine
Message 24 of 88
admin
in reply to: Anonymous

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

Message 25 of 88
Anonymous
in reply to: Anonymous


I went ahead and updated the add-in so that it
continues to create the three iProperties but also now creates two
parameters, one for the length and one for the width.  The attachment
contains the add-in and a readme on how to install it.  If a flat pattern
doesn't exist the parameters are still created but will have a value of 0. 
I've only done minimal testing so let me know if you find any problems.
--

Brian Ekins
Autodesk Inventor API

href="http://blogs.autodesk.com/modthemachine">http://blogs.autodesk.com/modthemachine
Message 26 of 88
Anonymous
in reply to: Anonymous

Thanks for the help! I've learned a lot through this excercise!
Message 27 of 88
admin
in reply to: Anonymous

Brian, 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.
Message 28 of 88
Anonymous
in reply to: Anonymous


Thanks for reporting this.  I looked at it and
there's an issue with using reference parameters.  I think they make the
most logical sense here but because of the problem I've updated the program to
use user parameters instead.  It seems to be working as expected now. 
Let me know if you find any other issues.  The updated version is
attached.  The dll version for this one is 1.2.0.0 if you ever need to see
which version you're running.
--
Brian Ekins
Autodesk Inventor
API

href="http://blogs.autodesk.com/modthemachine">http://blogs.autodesk.com/modthemachine


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Brian,
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.
Message 29 of 88
Anonymous
in reply to: Anonymous


One more (hopefully) follow-up.  I discovered
an issue with the iProperty values correctly updating.  The reason for this
is that I was creating the iProperties and the parameters with the same
name.  If you checked the box to expose the parameters as iProperties then
both the parameters and my program are setting the iProperty values, so the
value you get depends on who sets it last.  I found that it wasn't always
consistent either.

 

I've changed the program so that it now only
creates one iProperty for the sheet metal style and two parameters; one for
width and one for length.  But now I set these parameters to be exposed as
iProperties so the other to iProperties still get created but Inventor is doing
it instead of my program.  My program will update the parameter values when
the size of the flat changes and this will end up causing the iProperty values
to also update.  The only change someone that was using the original
version should see is that if a flat doesn't exist the value of the iProperties
will be "0 in" (or whatever the document unit is) instead of "None".  I've
attached the updated program plus I've attached the source code this time if
anyone wants to customize for their specific needs.  I changed the program
version to be 2.0.0.0
--
Brian Ekins
Autodesk Inventor API

href="http://blogs.autodesk.com/modthemachine">http://blogs.autodesk.com/modthemachine
Message 30 of 88
Anonymous
in reply to: Anonymous

I have been using IProperties in Inventor and it inserts the sheet metal length and width as just
width
length
I am using your sheet metal extents program and it works fine but I have to change width and length to your nomenclature, I was wondering if there was a way to change your sheetmetalwidth and sheetmetallength to just...............width and length so I dont have to go changing thousands of files

Thanks for reading
John
jagreco@yahoo.com
Message 31 of 88
Anonymous
in reply to: Anonymous

I'm having trouble installing this add-on. I just installed Inventor 2010. I just found this add-on, I didn't have it installed in 2009.

Attached is a screen capture of the error messages I get.

Can anybody point me in the right direction? I'd really love to get this working.
Message 32 of 88
RobJV
in reply to: Anonymous

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

Message 33 of 88
karthur1
in reply to: Anonymous

I 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
Message 34 of 88
Anonymous
in reply to: Anonymous


Are you sign'ing the assembly.

 

Go into the projects properties, signing tab. 

 

You should have Sign the Assembly checked, and a
strong name key file selected. 

 

 


--
KWiKMcad
Kent Keller


style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
I
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
Message 35 of 88
karthur1
in reply to: Anonymous

Kent,
I am only running the install file that they included. Where is the project properties you are refering to?

Kirk

Message 36 of 88
Anonymous
in reply to: Anonymous


Kirk,

 

Sorry, I should have looked back in the thread, I
thought this was some addin you were writing. 

 

Where did the addin come from. 


--
KWiKMcad
Kent Keller


style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"
dir=ltr>

Kent,
I am only running the install file that they included. Where is
the project properties you are refering to?


Kirk

Message 37 of 88
karthur1
in reply to: Anonymous


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

Message 38 of 88
Anonymous
in reply to: Anonymous


Kirk,

 

I see now.  My newsreader didn't have that
post, but I found it on the web side.  I downloaded the source and if I get
a chance I will see if I can find anything. Not sure when I will get a
chance though, I am pretty backed up with a project that is kicking
my you know what.   But if Brian posted it then I am probably
wrong on my guess of the problem, and hopefully he will take a look at it. 

 


--
KWiKMcad
Kent Keller


style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"
dir=ltr>


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

Message 39 of 88
karthur1
in reply to: Anonymous

Thanks
Message 40 of 88
Anonymous
in reply to: Anonymous

I am not sure if what I did fixed it, but after I did a few things it
started working here. I have only attached the dll. Save a copy of the
original, before overwriting it with this.

Then just run the batch file Brian included.

--
KWiKMcad
Kent Keller
"KArthur1" wrote in message news:6383571@discussion.autodesk.com...
Thanks

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

Post to forums  

Autodesk Design & Make Report