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: 

How to select all sheet metal parts with a certain thickness ?

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Kubuz
768 Views, 1 Reply

How to select all sheet metal parts with a certain thickness ?

How to select all sheet metal parts with a certain thickness ? 

 

Hi guys, 

I am new to programming, so maybe its a stuppid question !!

 

I am looking for a sample code to select all sheet metal parts with, for example thickness 0.5 mm.

 

i have been seaching for sample but did not find them. Hopefully someone very kind has a piece of code. 

Thanks all.

 

 

1 REPLY 1
Message 2 of 2
Vladimir.Ananyev
in reply to: Kubuz

I've developed a small sample code that could be a good start point for your program.

Note that sheet metal document is a subtype of PartDocument.

It has a lot of specific methods and properties.

Please refer Inventor API Help for more details.

 

Sub FindSheetsByThickness()

  'target thickness - search criteria
  Dim TargetThickness As Double
  TargetThickness = 0.05   'cm

  '-------------------------------
  Dim oAssyDoc As AssemblyDocument
  Set oAssyDoc = ThisApplication.ActiveDocument
  
  Dim oAssyDef As AssemblyComponentDefinition
  Set oAssyDef = oAssyDoc.ComponentDefinition
  
  'select set object of main assembly
  Dim oSSet As SelectSet
  Set oSSet = oAssyDoc.SelectSet
  
  Dim oDoc As Inventor.Document
  
  For Each oDoc In oAssyDoc.AllReferencedDocuments
    
    'verify document type (we are interested in metsl sheets only)
    If oDoc.ComponentDefinition.Type = kSheetMetalComponentDefinitionObject Then
      
      'extract thickness of this sheet part
      Dim oDef As SheetMetalComponentDefinition
      Set oDef = oDoc.ComponentDefinition
      Dim Thickness As Double
      Thickness = oDef.Thickness.Value  'returned in cm (base length units)
      
      If Math.Abs(Thickness - TargetThickness) < 0.00001 Then
        'thickness is equal to target thickness
        'find all child components for this part document
        'at all assembly levels
        Dim oColl As ComponentOccurrencesEnumerator
        Set oColl = oAssyDef.Occurrences.AllReferencedOccurrences(oDoc)
        If oColl.Count > 0 Then
          'select all found components
          Dim oOcc As ComponentOccurrence
          For Each oOcc In oColl
            Call oSSet.Select(oOcc)
          Next oOcc
        End If
      End If
      
    End If
  Next
  
  Beep
End Sub 

 Hope this helps.
Cheers,

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

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

Post to forums