Does anyone know a way or a code to physically change the sheet metal defaults using iLogic code, I want to change parts in my assembly without opening each individual part and changing it there. Please help!
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Solved by innovatenate. Go to Solution.
Dim oAssyDoc As AssemblyDocument oAssyDoc = ThisApplication.ActiveDocument Dim oDoc As Inventor.Document 'Add Input Box to retreive value here Dim oTargetTHK As Double oTargetTHK=25.4 'Check all referenced docs For Each oDoc In oAssyDoc.AllReferencedDocuments 'verify document type (we are interested in metal sheets only) If oDoc.ComponentDefinition.Type = 150995200 Then Dim oSheetMetalCompDef As SheetMetalComponentDefinition oSheetMetalCompDef = oDoc.ComponentDefinition ' Override the thickness for the document oSheetMetalCompDef.UseSheetMetalStyleThickness = False ' Get a reference to the parameter controlling the thickness. Dim oThicknessParam As Parameter oThicknessParam = oSheetMetalCompDef.Thickness ' Change the value of the parameter. oThicknessParam.Value = oTargetTHK Else End If Next
I was able to put the above code together after reviewing the example titled 'Sheet Metal Thickness Editing API Sample' from the Help pull down menu > Community Resources > Programming Help. Seems to work on the few simple examples I've tested.
Hope this helps.
I get an error when i copy this code into it's own rule that says "Error on Line 10 : 'For' must end with a matching 'Next'.
Am I doing something wrong or do I need to change anything in the code to personalize it?
Thank you
Hi rdiamond113,
Just a guess but did you happen to miss the last line when you copied the code?
The last line, Line 29, contains the missing Next statement.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
I added it to my assembly and when I ran the rule I received a ton of errors. I'm using this to change the sheet metal type of a round column cover consisting of 4 quarter "skins". I'm not sure what type of parts you're using this code with but some of the errors I got had to do with basically rebuilding the skin and what not, like bend radius errors and sketch geometry errors
Hi rdiamond113,
It worked for me using an assembly with 3 sheet metal parts and 2 non-sheetmetal parts.
I made a couple of modifications, by adding an update statement and adding an input list, but other than that it's the same.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Dim oAssyDoc As AssemblyDocument oAssyDoc = ThisApplication.ActiveDocument Dim oDoc As Inventor.Document 'Add Input Box to retreive value here Dim oTargetTHK As Double 'get user input 'oTargetTHK= InputBox("Enter Thickness", "iLogic", "0.2") 'create list of thicknesses dList = new double(){0.1,0.2,0.3} 'get user input from list oTargetTHK = InputListBox("Select a Thickness", dList, dList(0), "iLogic", "Thicknesses") 'Check all referenced docs For Each oDoc In oAssyDoc.AllReferencedDocuments 'verify document type (we are interested in metal sheets only) If oDoc.ComponentDefinition.Type = 150995200 Then Dim oSheetMetalCompDef As SheetMetalComponentDefinition oSheetMetalCompDef = oDoc.ComponentDefinition ' Override the thickness for the document oSheetMetalCompDef.UseSheetMetalStyleThickness = False ' Get a reference to the parameter controlling the thickness. Dim oThicknessParam As Parameter oThicknessParam = oSheetMetalCompDef.Thickness ' Change the value of the parameter. oThicknessParam.Value = oTargetTHK Else End If Next InventorVb.DocumentUpdate()
Okay I got it to work, the only issue I have now (LOL) is setting my specific sheet metal thickness, I changed where you had the thicknesses listed and found that it was setting the thickness to half what I ented in the list. how should I enter my standard sheet thicknesses?
I just realized the output from the code is metric, how can i change it to Inches?
Hi rdiamond113,
Internally Inventor works with centimeters as the default unit, to adjust your input to inches can multiply your input by 2.54 as shown in this example.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Dim oAssyDoc As AssemblyDocument oAssyDoc = ThisApplication.ActiveDocument Dim oDoc As Inventor.Document 'Add Input Box to retreive value here Dim oTargetTHK As Double 'get user input oTargetTHK= InputBox("Enter Thickness", "iLogic", "0.2")*2.54 'Check all referenced docs For Each oDoc In oAssyDoc.AllReferencedDocuments 'verify document type (we are interested in metal sheets only) If oDoc.ComponentDefinition.Type = 150995200 Then Dim oSheetMetalCompDef As SheetMetalComponentDefinition oSheetMetalCompDef = oDoc.ComponentDefinition ' Override the thickness for the document oSheetMetalCompDef.UseSheetMetalStyleThickness = False ' Get a reference to the parameter controlling the thickness. Dim oThicknessParam As Parameter oThicknessParam = oSheetMetalCompDef.Thickness ' Change the value of the parameter. oThicknessParam.Value = oTargetTHK Else End If Next InventorVb.DocumentUpdate()
Hi.
Sorry for pushing an old thread.
If i want to use the same ilogic script to change the bend radius in the sheet metal parts in my assembly, what do i chnage in the script? I have tried to just replace the word Thickness in the code to BendRadius, but it seems that it´s not that easy. 🙂
Best regards.
Lennart
Thickness and Bend Radius are simply parameters in the parts themselves and they can be controlled from the assy with an "=" statement like:
'Parameter("PART:1", "Thickness") = Parameter("ASSY:1", "BendRadius")
This would work if you had a User Parameter set up for BendRadius because you technically would not have that in an assembly.
I hope this helps!