• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor

    Reply
    Contributor
    rdiamond113
    Posts: 14
    Registered: ‎09-27-2012
    Accepted Solution

    Sheet Metal controlled through iLogic

    264 Views, 8 Replies
    03-04-2013 01:56 PM

    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!

    Inventor 2013 SP-1.1 Update 2, Windows 7, 64 bit

    "Pushing the envelope, just to watch it bend"
    Please use plain text.
    Product Support
    innovatenate
    Posts: 131
    Registered: ‎11-22-2011

    Re: Sheet Metal controlled through iLogic

    03-05-2013 05:21 PM 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
    Product Support Specialist
    Product Support Americas
    Autodesk, Inc.

    Please use plain text.
    Contributor
    rdiamond113
    Posts: 14
    Registered: ‎09-27-2012

    Re: Sheet Metal controlled through iLogic

    03-06-2013 06:46 AM 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

    Inventor 2013 SP-1.1 Update 2, Windows 7, 64 bit

    "Pushing the envelope, just to watch it bend"
    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,933
    Registered: ‎03-08-2006

    Re: Sheet Metal controlled through iLogic

    03-06-2013 07:23 AM in reply to: rdiamond113

    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



      solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.

    Please use plain text.
    Contributor
    rdiamond113
    Posts: 14
    Registered: ‎09-27-2012

    Re: Sheet Metal controlled through iLogic

    03-06-2013 07:42 AM in reply to: Curtis_Waguespack

    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

    Inventor 2013 SP-1.1 Update 2, Windows 7, 64 bit

    "Pushing the envelope, just to watch it bend"
    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,933
    Registered: ‎03-08-2006

    Re: Sheet Metal controlled through iLogic

    03-06-2013 08:05 AM in reply to: rdiamond113

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

     



      solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.

    Please use plain text.
    Contributor
    rdiamond113
    Posts: 14
    Registered: ‎09-27-2012

    Re: Sheet Metal controlled through iLogic

    03-06-2013 09:15 AM in reply to: Curtis_Waguespack

    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?

    Inventor 2013 SP-1.1 Update 2, Windows 7, 64 bit

    "Pushing the envelope, just to watch it bend"
    Please use plain text.
    Contributor
    rdiamond113
    Posts: 14
    Registered: ‎09-27-2012

    Re: Sheet Metal controlled through iLogic

    03-06-2013 10:12 AM in reply to: Curtis_Waguespack

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

    Inventor 2013 SP-1.1 Update 2, Windows 7, 64 bit

    "Pushing the envelope, just to watch it bend"
    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,933
    Registered: ‎03-08-2006

    Re: Sheet Metal controlled through iLogic

    03-06-2013 10:38 AM in reply to: rdiamond113

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

     



      solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.

    Please use plain text.