Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sheet Metal controlled through iLogic

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
rdiamond113
3446 Views, 10 Replies

Sheet Metal controlled through iLogic

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!

Product Design Suite 2015, Windows 7, 64 bit

"Pushing the envelope, just to watch it bend"
10 REPLIES 10
Message 2 of 11
innovatenate
in reply to: rdiamond113

  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.

 

 

 

 




Nathan Chandler
Principal Specialist
Message 3 of 11
rdiamond113
in reply to: innovatenate

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

Product Design Suite 2015, Windows 7, 64 bit

"Pushing the envelope, just to watch it bend"
Message 4 of 11

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

Message 5 of 11

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

Product Design Suite 2015, Windows 7, 64 bit

"Pushing the envelope, just to watch it bend"
Message 6 of 11

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()

 

Message 7 of 11

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?

Product Design Suite 2015, Windows 7, 64 bit

"Pushing the envelope, just to watch it bend"
Message 8 of 11

I just realized the output from the code is metric, how can i change it to Inches?

Product Design Suite 2015, Windows 7, 64 bit

"Pushing the envelope, just to watch it bend"
Message 9 of 11

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()

 

Message 10 of 11

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

Message 11 of 11
rdiamond113
in reply to: lennart.losjo

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!

Product Design Suite 2015, Windows 7, 64 bit

"Pushing the envelope, just to watch it bend"

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

Post to forums  

Autodesk Design & Make Report