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: 

Change sheet metal rule on a solid body with iLogic

62 REPLIES 62
SOLVED
Reply
Message 1 of 63
Anonymous
5006 Views, 62 Replies

Change sheet metal rule on a solid body with iLogic

Hello ,

 

Does anyone knows, if it is possible to set the sheet metal rule for a solid body in a Multi-body sheet metal?

You can set a different sheet metal rule for each solid body. So is it possible with ilogic to create a rule,

if this parameter = 5mm, then set sheet metal rule for a specific solid body? So, when the parameter change to

another value, you don't have to reset manualy the sheet metal rule for this specific solid body...

 

thx in advance!

62 REPLIES 62
Message 41 of 63
MjDeck
in reply to: JBerns

@JBerns, I attached a modified version of the Update Components rule from your part. This has a new subroutine:

Sub SetBodyStyle(bodyName As String, styleName As String)

This takes names instead of Inventor objects. It uses the names to find the objects. You can use that sub for any number of bodies in the same rule.


Mike Deck
Software Developer
Autodesk, Inc.

Message 42 of 63
JBerns
in reply to: MjDeck

That is incredible, Mike! @MjDeck

You converted what would have been 420 lines of code into a single line! And you saved that over and over for each solid body. Again - incredible!

 

The three challenges I mentioned earlier are solved. Time to continue development to discover new challenges.

Thanks again to @chandra.shekar.g and @Anonymous.

 

Regards,

Jerry

 

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 43 of 63
JBerns
in reply to: MjDeck

@MjDeck,

 

In my enthusiasm yesterday I realized I did not express proper gratitude for your contribution to solving the problem of sheet metal rule assignment to a solid body. I wish to correct that oversight.

 

Thank you, Mike, for your elegant solution to this challenge.

 

Kind regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 44 of 63
MjDeck
in reply to: JBerns

@JBerns, you're welcome. And thank you for bringing up this question. Reducing the amount of repeated code in a program is generally worthwhile. It makes the code easier to read and modify.


Mike Deck
Software Developer
Autodesk, Inc.

Message 45 of 63
Anonymous
in reply to: Anonymous

@MjDeck @chandra.shekar.g 

Hello,

 

Did you find any solution or workaround yet for the update problem we have?

i know it's while ago, so if you need any more info again on this, please let me know.

 

Thx in advance!

Message 46 of 63
MjDeck
in reply to: Anonymous

@Anonymous , we gave you a workaround that involves suppressing features before changing the sheet metal style, and unsuppressing them afterwards. Is it working for you?
I don't think we have anything else at this time. A better fix will require a change in the Inventor API. We have Autodesk issue number INVGEN-24081 to track this.


Mike Deck
Software Developer
Autodesk, Inc.

Message 47 of 63
Anonymous
in reply to: MjDeck

@MjDeck 

i added the suppression part in both of my rules (SheetMetalRuleZijplaatRTrog, SheetMetalRuleDekplaten).

when i hit the save button, no errors. when we use the update command, we first get the error for the bends, 

but after accept, the suppression starts and error is gone.

 

If it's not possible to avoid the error massage, then we will use it like it is.

it would be nicer without the error for my team to work with it.

 

Anyway, maybe there are some changes needed in my final SheetMetalRules. For instance, now i added the suppression part in both of the rules. is this nessecary? Maybe the suppression part should be in an additional rule?

Now i think the suppression of the bends runs 2 times. but i can't fix it... every change i make to the rules results in a faillure.

 

Also the try function doesn't have a catch part? Isn't this nessecary?

 

Is it possible to check both of my rules for improvement (I'm just an ilogic beginner, and these pieces of code are like chinees for me, so maybe i did something wrong trough the changes you've suggested)?

These pieces of code we will use for different engineering parts, so it would be nice to know if we are in the right direction, or if it could be improved.

 

I attached the parts once again.

 

Thx in advance! And thx for all the effort in the past, to make this work!

Message 48 of 63
MjDeck
in reply to: Anonymous

@Anonymous , you're right: I see the Update error after changing the Dikte zijplaat to 6 mm and the Dikte dekplaat to 4 mm. I'm not sure why I thought this was fixed. I'll take another look at it.

In reply to your questions:

 

> Maybe the suppression part should be in an additional rule?
The suppression and unsuppression parts make more sense if they're in the same rule. The idea is to suppress the features immediately before changing the sheet metal rule, and unsuppress them immediately afterwards. Those features will fail to update (and this shows the error message) if the sheet metal style doesn't match. But if they're suppressed, they pose no problem. Inventor doesn't need to update them.
That's the idea, anyway. However, since that's not sufficient to fix the problem, I'm wondering now if we can get rid of it.

 

Also the try function doesn't have a catch part? Isn't this necessary?

No, a Catch is not necessary. This is a Try ... Finally block. The Finally means: even if there was an exception (error) in the Try block, run the code in the Finally block. In this case, we want to make sure that the features get unsuppressed.

 

Is it possible to check both of my rules for improvement

One thing you could do is use the SetBodyStyle subroutine code that I attached to Message 41 above. I might be able to make other recommendations, but my first priority is to try to get rid of the update error message.


Mike Deck
Software Developer
Autodesk, Inc.

Message 49 of 63
Anonymous
in reply to: MjDeck

@MjDeck 

Thx agian!

We work a lot with multiple body (Skeleton files). I could avoid all sheet metal features by using fillets instead of bends, or extrusions instead of flanges. But it would be a pity not to use the new (implemented at inventor 

2018) sheet metal rule function to assign different sheet metal rules on different solid bodies, This was such an improvement for those who used skeleton modeling a lot. Now you can use al sheet metal funtions, even if your solid bodies have different thicknesses. 

Like i mentiond before, my ilogic experience is at starter level, and i think this is a problem that can only be solved by more experienced users.

I'm sure if there's an easy routine to set those sheet metal syles, more skeleton users would be greatfull for this!

 

Thx for the info you gave me, and for helping me out on this!

 

Message 50 of 63
Anonymous
in reply to: MjDeck

@MjDeck 

i tried to use this new sub routine (without using the suppression function yet), but this doesn't work for me...

I think i did something wrong. Maybe my case, that i used before is in the wrong place?

Maybe you can see what's the problem here?

Sub Main()

Dim oDoc As PartDocument

oDoc = ThisDoc.Document

'Call oDoc.Update()

oDef = oDoc.ComponentDefinition


'For Each oBody In oDef.SurfaceBodies
'	MessageBox.Show("Body Info: " _
'	& vbCr _
'	& vbCr & "Name: " & vbTab & vbTab & vbTab & oBody.Name _
'	& vbCr & "Appearance Source Type: " & vbTab & oBody.AppearanceSourceType _
'	& vbCr & "Is Solid: " & vbTab & vbTab & vbTab & oBody.IsSolid _
'	& vbCr & "Is Transient: " & vbTab & vbTab & oBody.IsTransient _
'	& vbCr & "Type: " & vbTab & vbTab & vbTab & oBody.Type _
'	& vbCr & "Visible: " & vbTab & vbTab & vbTab & oBody.Visible _
'	& vbCr, "Solid Body Info")
'Next


'
' Change rule assignment based on user selection
'

SetBodyStyle("Zijplaat R Trog", DikteZijplaat)


SetBodyStyle("Dekplaat 1", DikteDekplaat)


End Sub


' This variable is shared between the Sub's
Private oDef As SheetMetalComponentDefinition

Sub SetBodyStyle(bodyName As String, styleName As Double)
	
	Dim oBodyFound As SurfaceBody = Nothing
	Dim oStyleFound As SheetMetalStyle = Nothing
	Dim oBody As SurfaceBody
	
	
	For Each oBody In oDef.SurfaceBodies
		If oBody.Name = bodyName Then
			oBodyFound = oBody
			Exit For
		End If
	Next

Select Case styleName

Case 2
			For Each oStyleFound In oDef.SheetMetalStyles
    
			If oStyleFound.Name = "PLAAT KGW 002 S235JR" Then
    
			Exit For
    
			End If
    
			Next
Case 3
			For Each oStyleFound In oDef.SheetMetalStyles
    
			If oStyleFound.Name = "PLAAT 003 LASERFORM S235JR" Then
    
			Exit For
    
			End If
    
			Next
Case 4
			For Each oStyleFound In oDef.SheetMetalStyles
    
			If oStyleFound.Name = "PLAAT 004 LASERFORM S235JR" Then
    
			Exit For
    
			End If
    
			Next
Case 5
			For Each oStyleFound In oDef.SheetMetalStyles
    
			If oStyleFound.Name = "PLAAT 005 LASERFORM S235JR" Then
    
			Exit For
    
			End If
    
			Next
			
Case 6
			For Each oStyleFound In oDef.SheetMetalStyles
    
			If oStyleFound.Name = "PLAAT 006 LASERFORM S235JR" Then
    
			Exit For
    
			End If
    
			Next
Case 8
			For Each oStyleFound In oDef.SheetMetalStyles
    
			If oStyleFound.Name = "PLAAT 008 LASERFORM S235JR" Then
    
			Exit For
    
			End If
    
			Next
End Select




	oStyleFound = oDef.SheetMetalStyles(styleName) ' This doesn't need a loop. If the style is not found, there will be an error.
	
	If oStyleFound IsNot Nothing AndAlso oBodyFound IsNot Nothing AndAlso
			oDef.GetBodySheetMetalStyle(oBodyFound) IsNot oStyleFound Then
		Call oDef.SetBodySheetMetalStyle(oBodyFound, oStyleFound)
	End If

'		MessageBox.Show(oBodyFound.CreatedByFeature, "Title Comp Def")
'		MessageBox.Show(oBodyFound.DataIO, "Title Name")
'		MessageBox.Show(oBodyFound.Edges, "Title Name")
'		MessageBox.Show(oBodyFound.IsPointInside, "Title Name")
'		MessageBox.Show(oBodyFound.Parent, "Parent")
'		MessageBox.Show(oBodyFound.RangeBox, "Title Name")
'		MessageBox.Show(oBodyFound.Vertices, "Title Name")
'		MessageBox.Show(oBodyFound.Volume, "Title Name")
'		MessageBox.Show(oBodyFound.Wires, "Title Name")
End Sub

Thx! 

Message 51 of 63
MjDeck
in reply to: Anonymous

@Anonymous , I attached a fixed version of your rule. You were using the thickness parameter (a number) as the style name (a string). That won't work. Given the thickness, you need to get the sheet metal rule name. You already had code to do that, but it wasn't set up to use the new method. So my biggest change was to modify your old code that finds the style name given the thickness.

I also added the feature suppression code. But I moved it so that it's only done once. The style for both bodies is set while the features are suppressed.


Mike Deck
Software Developer
Autodesk, Inc.

Message 52 of 63
Anonymous
in reply to: MjDeck

@MjDeck 

Thank you for the fixed version, i tested this, everything works fine! Now we can fit all sheet metal updates in one rule, and add sheet metal styles and bodies in the same rule. This saves us a lot of time!

I had to add a rebuild to the rule, the sheet metal styles were updatet, but the bend radius of my bodies were still at the previous thickness. after the rebuild, they were set at the right value.

 

i still got 2 questions about this.

 

you said now the rule only suppresses the features once. but when you use the rule to update more than one solid body, i think the rule does the suppression for each solid bodie agian. i'm i correct?

 

And we use the suppressions in the rule to avoid the update error, but this is still the same i guess? wen you hit the update button instead of the save command, you first get an error you need to accept, after accepting, you have the same result as when you hit the save command.

And this is something i can't get, what's the difference between saving the file (no error message), and updating (bend error message)

 

If these are things that can't be fixed, no problem, i'm very pleased with the result, and i want to thank you again for your quick responses, and helping me out on this!

 

Thx!!

 

Message 53 of 63
MjDeck
in reply to: Anonymous

@Anonymous , the suppressions are there to allow the iLogic rule to set the sheet metal style. Without that workaround, this error will often pop up and the rule will not complete:
SetSheetMetalRuleError.png 

We are developing a better solution (Autodesk internal number INVGEN-24081). When that is available, the suppression should no longer be required.

I hadn't noticed that a Rebuild was required to set the bend radii to the correct value. Thanks for pointing that out. We're looking into it now.

 

I actually haven't seen the difference between saving the file and updating. I'll try again and ask other people to look at it as well.


Mike Deck
Software Developer
Autodesk, Inc.

Message 54 of 63
Anonymous
in reply to: MjDeck

@MjDeck 

 

Thx again!

 

Let me know if there are any new solutions or updates.

When this better solution (INVGEN-24081) is available, will i get a notification of that?

Message 55 of 63
MjDeck
in reply to: Anonymous

When the fix is available in an update, we will post a message on this forum thread and mention your name. So you should receive a notification.


Mike Deck
Software Developer
Autodesk, Inc.

Message 56 of 63
Anonymous
in reply to: MjDeck

@MjDeck 

Hello,

Is there any solution yet for this problem (Autodesk internal number INVGEN-24081)?

The same for the other point outs (Rebuild, and difference between save and update)?

 

Thx in advance!

Message 57 of 63
MjDeck
in reply to: Anonymous

@Anonymous , we have a fix for it in internal builds for the next release of Inventor. Are you in the Inventor Beta feedback community?


Mike Deck
Software Developer
Autodesk, Inc.

Message 58 of 63
Anonymous
in reply to: MjDeck

@MjDeck 

No i'm not.

how can i join?

Does this mean the fix will only be available with the release of inventor 2021?

 

Thx for your reply!

Grtz

Message 59 of 63
MjDeck
in reply to: Anonymous

@Anonymous , that's right: our plan is to release it only in Inventor 2021.

I'd appreciate it if you can test out our fix. You can apply to the Beta program at 

http://Autode.sk/InventorBeta


Mike Deck
Software Developer
Autodesk, Inc.

Message 60 of 63
Anonymous
in reply to: MjDeck

@MjDeck 

Hello,

 

I joined the autodesk beta program, and i've installed 2021 Beta version.

 

First of all i tried everything as we use it today (with the suppressions).

I see that we still need to use the save command instead of the update command to avoid the error message.

This only worked after i configured my external ilogic rules, without these, the save command doesn't do anything and is a manually update needed. When the error is accepted (after manually update), routine continious and all error are gone, just like before.

 

Then i tried to adapt the rule and remove the suppression part, but i can't figure out why it doesn't work for me...

What do i need to change in the rule given at MESSAGE 51? I guess it isn't that simple like just delete the suppression part with the try and finally block? 

I only get errors and a routine that doesn't do the job anymore... Probably because of my pour ilogic skills.

So i can't really tell if the fix (avoid suppression and avoid a final rebuild to set the correct radius) works for me...

 

I can only see that the difference between save command and update command is still there. not that this is my biggist issue, but it would be great to avoid the errors when using the update command.

 

Can i post this still here? Or should i'll post this anywhere at the feedback community?

 

Anyhow, i can't wait to test out other improvements in this beta version!

 

Thx in advance!

 

 

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

Post to forums  

Autodesk Design & Make Report