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!
Solved! Go to Solution.
Solved by chandra.shekar.g. Go to Solution.
I have encountered new challenges using a multi-body sheet metal part in the design process. I would welcome assistance from the Community.
Challenge 1:
I cannot assign a rule from the library to a solid body if it is not already in use by another solid body.
I would like to be able to assign any rule from the library to a solid body.
Challenge 2:
I would also like to find a more efficient way to assign the rule to each solid body in the design. Using the code example above would require a For-loop and Select Case for each component. With potential for 6 - 8 parts in a design, that would require a lot of repetitive code. Instead, it would be useful if functions could be called passing it the component name and required sheet metal rule.
Challenge 3:
Is it the best practice to change the rule and dimensions in the multi-body part or at the assembly level? Either way, I need to be able to select any rule from the library and assign it to a solid body. This of course will update the part and in turn, the assembly.
Thank you for your time and attention. I look forward to your replies.
Regards,
Jerry
In sheet metal defaults -> style and standard editor -> change filter options to all styles.
I hope this helps you on the way for you first challenge.
For your other challenges, i can't help you yet, since i'm just at the beginning stage for using and programming with iLogic. So i also have to find my way trought this.
Best regards
@Anonymous,
Thanks. That was the style info I was seeking.
Regards,
Jerry
@Anonymous,
Unfortunately, the filter is already set to 'All Styles' in the Styles and Standards Editor.
I am under the assumption that if a dialog box can list all the styles, then iLogic (VB / API) should also be able to access the styles. I hope this assumption is true.
Perhaps @chandra.shekar.g can shed some light on how to access and select a style (sheet metal rule) from the library to assign to a solid body within the master part.
Regarding Challenge 2, perhaps this article by @Anonymous will be helpful in assigning the rule to specific solid bodies.
Regarding Challenge 3, I hope to continue to drive control from the sheet metal multi-body part. Changing the assigned rule for a solid body can easily communicate new dimensions to surrounding bodies in the master part.
Regards,
Jerry
@Anonymous,
Issue is reproducible at my end as well. For further investigation, issue is reported to engineering team. I will get back to you after hearing from engineering team.
Thanks and regards,
Thank you for confirming the issue. I look forward to hearing of a solution.
From the forums, I hope to discover how to create a function to which I could pass the name of the sheet metal body/feature and the sheet metal rule. This would improve the code efficiency. Would you know of any code examples that would match this goal?
Regards,
Jerry
Thanks for suggestion,
Currently, there is no iLogic function which can accepts sheet metal rule and solid body as parameters.
Please post this wish list at idea station using below link.
https://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232
Thanks and regards,
I understand that there is no specific function for this task. My goal was to create a user-defined function to which you could pass the two parameters - the surface body and the rule.
For example, Function Update_Surface_Body (Surface_Body, SM_Rule)
I attempted to build the function using your code example (message 6 of this thread) provided to @Anonymous, but I struggled with global and local declared parameters. I was hoping the API might offer a search tool, like the AutoLISP TBLSEARCH function, to find the surface body or a rule instead of having to do a For-Next loop each time to find the surfacebody/rule.
I am confident I can develop this with the assistance of the Community. Thanks again, Chandra.
Regards,
Jerry
@Anonymous,
Try below workaround iLogic code to update sheet metal rule.
In "SheetMetalRuleDekplaten" rule at SchetspartTrog1.ipt file.
Sub Main() Dim oDoc As PartDocument oDoc = ThisApplication.ActiveDocument Call oDoc.Update() Dim oDef As SheetMetalComponentDefinition oDef = oDoc.ComponentDefinition Dim oBody As SurfaceBody For Each oBody In oDef.SurfaceBodies If oBody.Name = "Dekplaat 1" Then Exit For End If Next Dim oStyle As SheetMetalStyle Select Case DikteDekplaat Case 2 For Each oStyle In oDef.SheetMetalStyles If oStyle.Name = "PLAAT KGW 002 S235JR" Then Exit For End If Next Case 3 For Each oStyle In oDef.SheetMetalStyles If oStyle.Name = "PLAAT 003 LASERFORM S235JR" Then Exit For End If Next Case 4 For Each oStyle In oDef.SheetMetalStyles If oStyle.Name = "PLAAT 004 LASERFORM S235JR" Then Exit For End If Next Case 5 For Each oStyle In oDef.SheetMetalStyles If oStyle.Name = "PLAAT 005 LASERFORM S235JR" Then Exit For End If Next Case 6 For Each oStyle In oDef.SheetMetalStyles If oStyle.Name = "PLAAT 006 LASERFORM S235JR" Then Exit For End If Next Case 8 For Each oStyle In oDef.SheetMetalStyles If oStyle.Name = "PLAAT 008 LASERFORM S235JR" Then Exit For End If Next End Select If Not oStyle Is Nothing AndAlso Not oBody Is Nothing AndAlso oDef.GetBodySheetMetalStyle(oBody) IsNot oStyle Then Logger.Info("changing body {0} --> {1}", oBody.Name, oStyle.Name) ' Suppress some feature to avoid an update error. Feature.IsActive("Bend 1 Zijplaat R Trog") = False Feature.IsActive("Bend 2 Zijplaat R Trog") = False Feature.IsActive("Bend 1 Dekplaat 1") = False Feature.IsActive("Bend 2 Dekplaat 2") = False Try Call oDef.SetBodySheetMetalStyle(oBody, oStyle) Finally ' Unsuppress the features after the style has been changed. Feature.IsActive("Bend 1 Zijplaat R Trog") = True Feature.IsActive("Bend 2 Zijplaat R Trog") = True Feature.IsActive("Bend 1 Dekplaat 1") = True Feature.IsActive("Bend 2 Dekplaat 2") = True End Try End If End Sub
In "SheetMetalRuleZijplaatRTrog" rule at SchetspartTrog1.ipt file.
Sub Main() Dim oDoc As PartDocument oDoc = ThisApplication.ActiveDocument Call oDoc.Update() ThisApplication.UserInterfaceManager.DoEvents() Dim oDef As SheetMetalComponentDefinition oDef = oDoc.ComponentDefinition Dim oBody As SurfaceBody For Each oBody In oDef.SurfaceBodies If oBody.Name = "Zijplaat R Trog" Then Exit For End If Next Dim oStyle As SheetMetalStyle Select Case DikteZijplaat Case 3 For Each oStyle In oDef.SheetMetalStyles If oStyle.Name = "PLAAT 003 LASERFORM S235JR" Then Exit For End If Next Case 4 For Each oStyle In oDef.SheetMetalStyles If oStyle.Name = "PLAAT 004 LASERFORM S235JR" Then Exit For End If Next Case 5 For Each oStyle In oDef.SheetMetalStyles If oStyle.Name = "PLAAT 005 LASERFORM S235JR" Then Exit For End If Next Case 6 For Each oStyle In oDef.SheetMetalStyles If oStyle.Name = "PLAAT 006 LASERFORM S235JR" Then Exit For End If Next Case 8 For Each oStyle In oDef.SheetMetalStyles If oStyle.Name = "PLAAT 008 LASERFORM S235JR" Then Exit For End If Next End Select If Not oStyle Is Nothing AndAlso Not oBody Is Nothing AndAlso oDef.GetBodySheetMetalStyle(oBody) IsNot oStyle Then Logger.Info("changing body {0} --> {1}", oBody.Name, oStyle.Name) ' Suppress some feature to avoid an update error. Feature.IsActive("Bend 1 Zijplaat R Trog") = False Feature.IsActive("Bend 2 Zijplaat R Trog") = False Feature.IsActive("Bend 1 Dekplaat 1") = False Feature.IsActive("Bend 2 Dekplaat 2") = False Try Call oDef.SetBodySheetMetalStyle(oBody, oStyle) Finally ' Unsuppress the features after the style has been changed. Feature.IsActive("Bend 1 Zijplaat R Trog") = True Feature.IsActive("Bend 2 Zijplaat R Trog") = True Feature.IsActive("Bend 1 Dekplaat 1") = True Feature.IsActive("Bend 2 Dekplaat 2") = True End Try End If End Sub
Thanks and regards,
Can you please explain your situation with sample code?
For each loop is required to find SurfaceBody / rule in code example (message 6 of this thread). Transferring variables from one iLogic to another iLogic may not feasible.
For sample code on global variable declaration, refer below link.
Thanks and regards,
Thanks again for helping me out on this!
I've changed my rules to the new ones. At first i thought it wasn't working. Because when i opened the parts for the first time, and changed 2 parameters, then i still got an error after hitting the save button. but when i hit run all rules again, the errors are gone. and if i changed again 2 parameters at the time and hit the save button, it works fine. i did this a couple of times, and it worked every time. When i closed the documents and reopend them, i had the same problem, the first time errors, and after running al rules again, everything works fine. if i hit the update command instead of save butten, i also first get an error message eacht time. i tought with the suppression you added to the rule, this would be gone, and it would work fine also if we hit the update command instead.
I think we are almost there, since it works most of the time. but it would be great if everything works from the first time we've opend the files. and also that it wouldn't matter if we hit the save button or the update command. now we still have the error when we use the update command.
When i hit run al rules the first time i opend the document, before i change the parameters, it works also fine. so i tought mabe i could run my rules when opening the document, but this doesn't give the same result. errors are still there.
I added another video, to explain more, and the parts with the new rules, so maybe you can reproduce the problem, and if possible, helping out on a solution to avoid the last bugs.
If you need anything else, or more explanation, let me know.
Thx in advance!!!
https://knowledge.autodesk.com/community/screencast/fec2596a-2537-422c-8264-dfb2c021bb20
I was surprised that a user must use a For-Next loop to find a surface body or a sheet metal rule or most anything. I would have thought there would have been a built-in search function. If For-Next loop is required, then that is what I will use.
Until the issue is resolved for selecting a sheet metal rule that is not in use, there is not much point in further development.
@Anonymous, are you able to assign a sheet metal rule from your library to a surface body?
I found this API Sample that iterates through the Sheet Metal Styles (rules):
Inventor - API - Sheet Metal Style Display sample
It can determine if a style is 'In Use' and its location (Local, Library, Both).
Perhaps some code from this sample can be used to assign a sheet metal rule to a surface body. The pursuit continues.
Regards,
Jerry
@Anonymous,
Are all rules in use by a solid body in your multi body part?
In my test, I created three solid bodies, each assigned a different sheet metal rule. In the iLogic form I have many rules available, but only those currently in use can be assigned to a solid body.
Would you mind testing your code on a multi body part with just two solids? As I recall, your library also has several sheet metal rules.
Thanks. I look forward to the replies.
Regards,
Jerry
@Anonymous, I'm working with @chandra.shekar.g on this.
I found a way to avoid the situation where you have to run the rules manually after the first changes in a session. To fix that, add this line near the top of the SheetMetalRuleDekplaten rule:
trigger = DikteZijplaat & DikteDekplaat
This statement can actually go anywhere in the rule, but it makes sense to put it near the top (after Sub Main).
Without this change, the rule would run only when DikteDekplaat changes. With this new statement, the rule will also run when DikteZijplaat changes. I'm not exactly sure why this is required, but I think it has something to do with dependencies between features.
This change does not get rid of the Update pop-up warning dialog.
Thx again for helping out. This works fine now.
Let me know if you find any solution for the update problem. i think this has to work somehow, since we don't get any errors when hitting the save button instead.
Thx in advance!
When i delete all the local sheet metal styles in my document, and then run my rules with the changes i've made, then inventor automaticly create the sheet metal rules from my library in my local document.
So each library sheet metal style is available, no problems with that at my end here...
@Anonymous,
I have the sheet metal assignment to a surface body working now - it was an error on my part. My apologies all.
Now to work on efficiency.
A function to test and change the body rule assignment will be essential to keep this manageable. However, I am struggling with the development of the function, especially passing the argument, which will be the surface body name.
I have attached a part with the iLogic developed to-date. Thanks again, @chandra.shekar.g, for the code snippets. And thanks again, @Anonymous, for testing sheet metal rules in library, but not in use in the part.
Regards,
Jerry
Can't find what you're looking for? Ask the community or share your knowledge.