Sheet Metal Extents

Sheet Metal Extents

Anonymous
Not applicable
11,940 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,941 Views
87 Replies
Replies (87)
Message 61 of 88

Mike.Wohletz
Collaborator
Collaborator

Well I don't remember where the post was from last time, but I did download it from here and then rebuild it again with .NET 3.5 and also updated to the 2012 reference and it all came back what the real problem may have been before. When I updated the reference I had two errors with the following lines; 

 

          If Math.Abs(invFlatPattern.Length - invLengthParameter.Value) > 0.0000001 Then
                        invLengthParameter.Value = invFlatPattern.Length
                        madeChange = True
                    End If

                    If Math.Abs(invFlatPattern.Width - invWidthParameter.Value) > 0.0000001 Then
                        invWidthParameter.Value = invFlatPattern.Width
                        madeChange = True
                    End If

 I have changed this to be as follows;

 

          If Math.Abs(invFlatPattern.Length - CType(invLengthParameter.Value, Double)) > 0.0000001 Then
                        invLengthParameter.Value = invFlatPattern.Length
                        madeChange = True
                    End If

                    If Math.Abs(invFlatPattern.Width - CType(invWidthParameter.Value, Double)) > 0.0000001 Then
                        invWidthParameter.Value = invFlatPattern.Width
                        madeChange = True
                    End If

 The conversion of the object to type Double got rid of the error and I think it should now work in 2013. 

The attached was not tested so please let me know if you have any errors. 

 

0 Likes
Message 62 of 88

Anonymous
Not applicable

That works.  Thank you.

0 Likes
Message 63 of 88

RobJV
Collaborator
Collaborator

Hi Brian,

 

Could you please post your updated program on here when it is done for 2013.

 

Thanks so much!

0 Likes
Message 64 of 88

karthur1
Mentor
Mentor

Rob,

In the meantime, I opened the zip that Mike posted.  In it is a SheetMetalExtents.dll.  I overwrote the .dll that was on my hard drive with this one.

 

That got me going again in 2013.

 

Kirk

0 Likes
Message 65 of 88

RobJV
Collaborator
Collaborator

Thanks Kirk.  I hope to be installing 2013 in the next week or so.  I will do the same as you until I have Brian's updated program.  Thanks to Mike as well.

 

Rob

0 Likes
Message 66 of 88

ekinsb
Alumni
Alumni

I've updated the program.  You can find more info and the update here:

 

http://modthemachine.typepad.com/my_weblog/2012/05/sheet-metal-extents-add-in-update.html

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 67 of 88

Anonymous
Not applicable

Hi I was able to get the 'Mike' version of this program running on 2013.

 

At first when I ran the ..64.bat I got an error with something to do with the codebase switch.

 

I just edited the .bat file and removed the switch and it seems like it is working so far...

Just want to know if this is ok??

 

For what ever reason I could not get the 'Brian' version to work...I tried the supplied installer, as well as ensuring the files were copied to the correct roaming folder...(as well as a whole bunch of other folders)..but no go

 

I am on windows 7 64 bit.

 

Regards

0 Likes
Message 68 of 88

Anonymous
Not applicable

I have used this addon for years and was happy to discover there is an update for 2013. Although I cannot get it running. I have installed using the Installer and even tried manually to get to load, no joy. What I'm I missing?

0 Likes
Message 69 of 88

Mike.Wohletz
Collaborator
Collaborator

Do you get any errors when you run the Install_64.bat file? If so what are they. Also it may be something to try and change the following line in the .BAT file:

 

C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\RegAsm.exe /codebase SheetMetalExtents.dll

 to this

 

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe /codebase SheetMetalExtents.dll

 

I have not tried this but have been told that it does work as well. 

0 Likes
Message 70 of 88

Anonymous
Not applicable

@Mike.Wohletz wrote:

Do you get any errors when you run the Install_64.bat file? If so what are they. Also it may be something to try and change the following line in the .BAT file:

 

C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\RegAsm.exe /codebase SheetMetalExtents.dll

 to this

 

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe /codebase SheetMetalExtents.dll

 

I have not tried this but have been told that it does work as well. 


I have made that same correction to the .bat file. After running the .bat at the Cmd Prompt I got the following:

 

RegAsm : warning RA0000 : Registering an unsigned assembly with /codebase can cause your assembly to interfere with other applications that may be installed on the same computer. The /codebase switch is intended to be used only with signed assemblies. Please give your assembly a strong name and re-register it.
Types regisetered succesfully

It still doesn't work.

0 Likes
Message 71 of 88

karthur1
Mentor
Mentor

I really had to bring this up... but I am having trouble with this again.  When I create a new part and flatten it, I get the SM extents in the parameters.  Problems start when I make a change to the part. As soon as I exit the sketch, I get an error "Unexpected error while updating the property values with the sheet metal extents.  The results should not be used.".

 

2012-10-25_1420.png

 

Of course, when I check the parameters, the value is not correct.  I can do a Manage>Rebuild and that will update the parameter values. Then if I make another change to the sketch, I get the error again.

 

I am using the .dll that is in Mike's .zip file above on 5-1-2012.`

 

I am running SP1.1..... not sure if that is what broke this or not.

 

Anyone else seeing this?

 

Kirk A.

Windows 7 x64 -12 GB Ram
Intel i7-930 @ 3.60ghz
nVidia GTS 250 -1GB (Driver 301.42)
INV Pro R2013, SP1.1
Vault 2013

0 Likes
Message 72 of 88

RobJV
Collaborator
Collaborator

I just installed SP1 today and will let you know if i notice anything.  I use this addin daily so will let you know ASAP.

 

I will tell you that since running 2013 with this addin, I have noticed that message way more than in the past.  I know some of the things that will cause that message every time like holes and cuts in the sheetmetal part or holes made by the bolted connection generator.  I have definitely noticed that I need to perform rebuilds more often at the part level to ensure the addin is giving me the most up to date numbers.

 

Rob

0 Likes
Message 73 of 88

karthur1
Mentor
Mentor

As an alternative, here is the iLogic code to do this.

0 Likes
Message 74 of 88

Anonymous
Not applicable

I loved this dll add-on but gave up on it a few months ago because of this problem. What I ended up doing was using the same function from iPropWiz (http://www.ipropwiz.com/index.html) which I already had (and thoroughly recommend) and mapped the 2 custom properties I needed (SheetMetalLength and SheetMetalWidth) to the 2 iPropWiz properties (ipwFlatExtentsX and ipwFlatExtentsY).

0 Likes
Message 75 of 88

karthur1
Mentor
Mentor

Brendan,

There is a slight difference between the iLogic code and the mapping that you are doing with iPropsWiz.  The iLogic code above actually writes the SheetMetalLength and SheetMetalWidth as user parameters in the part properties. The parameters are then used in the idw parts lists.

 

The way that I have our idws set-up (from way back), one column is the "Cutlength" and this is mapped to the sheetmetallength in the user parameters.

 

Not saying either way is right or wrong, its just a different way to skin the cat.Smiley Happy

 

Kirk

0 Likes
Message 76 of 88

karthur1
Mentor
Mentor

Trying to correct this issue, I tried the three different methods that Brian talks about on his blog.  I could not get any of them to work, but I was able to use the .dll from the Installer method.

 

I used the old "Install_64.bat" to get it installed, then overwrote the old dll with the one from the Installer method.  It works now.

0 Likes
Message 77 of 88

ekinsb
Alumni
Alumni

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.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 78 of 88

Sonny4
Participant
Participant

How do you change the rule if you do not want to use inches. (mm)

0 Likes
Message 79 of 88

Anonymous
Not applicable

Thanks for the update, this corrected my install problem!

 

Regards,

John


@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.


 

0 Likes
Message 80 of 88

eric
Participant
Participant
Can you update this code to run in 2014 please.
0 Likes