Get Content Centre Shape with iLogic

Get Content Centre Shape with iLogic

jmfowler1996
Advocate Advocate
941 Views
5 Replies
Message 1 of 6

Get Content Centre Shape with iLogic

jmfowler1996
Advocate
Advocate

Hi.

 

Is there a way to use ilogic to return the structural shape of a part (from the content centre)?

i.e. to distinguish between SHS, CHS, UB, etc.

 

 

 

I'm currently working on a rule from my drawing to aid filling in the 'description' collumn of the B.O.M.

If I could find the shape used, then the rule could fill in a default description:

 

 

        [...]
Case "CHS" Try AutoName = "CHS " & Parameter(oPart, "G_H") & " OD x " & Parameter(oPart, "G_T") & " WT" Catch MessageBox.Show("Error getting parameters", "iLogic") AutoName = "" End Try
[...]

 

I've already got a working rule to edit the parts' descriptions, but for now, I need to manually fill in the 'type' of shape to base the default name structure on.

 

Anybody have any ideas?

Thanks!

0 Likes
Accepted solutions (2)
942 Views
5 Replies
Replies (5)
Message 2 of 6

AlexFielder
Advisor
Advisor
Accepted solution

HI @jmfowler1996,

 

I suppose you might be able to query the iProperties for each Content Center part? Although I'm not sure what differentiating property information might be contained there for the specific families you are using.

 

I guess failing that, you could look for differences between the Part number(s) as those should be specific for each unique new member?

 

Cheers,

 

Alex.

0 Likes
Message 3 of 6

jmfowler1996
Advocate
Advocate

Thanks, Alex.

 

I just wrote a description of why I couldn't use either of the methods you described, but then I changed my mind.

My plan is to search for particular parameter names in the test part (as you suggested), and create a list of which ones exist. I will then test the list against expected parameter lists for particular shapes.

 

I will post back with my results.

 

 

 

For now, here is past me trying to figure things out:

 

/////////

 

Do you mean search to see if specific parameters exist in the part,

i.e. if "G_T1" exists, then it must be flange channel?

That's a good idea, but it could get very complicated.

to check if a part is round bar, I would need to test that it had "G_H" (outside diameter), but also not have "G_T" (wall thickness), or else it would be hollow section.

It would take a lot of time and some very messy code.

          *UPDATE: on second thoughts, this might not be too bad. I think I will try this.

 

As far as part numbers, that's the way I first thought to do it, but there's no way to determine the strutural shape from them. Some examples are:

"BS 4 - 200 x 90 - 100"    (PFC)

"BS EN 10219-2 - 88.9 x 6 - 100"    (CHS)

"BS EN 10219-2 - 70 x 50 x 4  - 100"    (RHS)

There doesn't seem to be any way of distinguishing everything. (counting how many "x"s there are would narrow it down though.)

 

I wish that the part names were based on the structural shapes. That would make this a whole lot easier.

 

I wonder if it is worth modifying the content centre files to give them a parameter named 'Shape'-

          *I realise i'm an idiot at this point.

0 Likes
Message 4 of 6

jmfowler1996
Advocate
Advocate
Accepted solution

Here's what I came up with.

It works perfectly and distinguishes between: PFC, RHS, CHS, RD BAR, UC, RSA, F/BAR.

 

 

            'Test for parameters
            Try
            parametro = Parameter(oPart, "G_NG")
            G_NG = 1
            Catch
            G_NG = 0
            End Try
            
            Try
            parametro = Parameter(oPart, "G_T")
            G_T = 1
            Catch
            G_T = 0
            End Try
            
            Try
            parametro = Parameter(oPart, "G_W")
            G_W = 1
            Catch
            G_W = 0
            End Try
            
            Try
            parametro = Parameter(oPart, "G_ER")
            G_ER = 1
            Catch
            G_ER = 0
            End Try
            
            Try
            parametro = Parameter(oPart, "G_T1")
            G_T1 = 1
            Catch
            G_T1 = 0
            End Try
            
            'Compare to expected parameters
            If G_NG = 1 Then
            AutoType = "PFC"
            ElseIf G_T1 = 0 And G_W = 1 And G_ER = 0 And G_T = 1 Then
            AutoType = "RHS"
            ElseIf G_T = 1 And G_W = 0 Then
            AutoType = "CHS"
            ElseIf G_T = 0 And G_W = 0 Then
            AutoType = "RD BAR"    
            ElseIf G_T1 = 1 And G_NG = 0 Then
            AutoType = "UC"
            ElseIf G_ER = 1 Then
            AutoType = "RSA"
            ElseIf G_W = 1 And G_T = 0 Then
            AutoType = "F BAR"
            Else
            AutoType = ""
            End If

 

Really happy how this has turned out.

My rule now goes from picking a line of an item on a drawing, to creating a full description which is exported to the part's 'Description' iProperty, and so is shown in the B.O.M.

 

If anybody is interested in the full iLogic rule I'm using, let me know and i'll post it here.

0 Likes
Message 5 of 6

GeorgK
Advisor
Advisor

Hello @jmfowler1996,

 

please could you post your code? Thank you

 

Georg

0 Likes
Message 6 of 6

jmfowler1996
Advocate
Advocate

Hi Georg.

 

I'm glad you asked.

I hope this code helps you out.

 

 

'On Error Resume Next

    'part from line

    
    Dim oDoc As Inventor.Document
    oDoc = ThisApplication.ActiveDocument
 
    'Dim oSelectSet As Inventor.SelectSet
    'oSelectSet = oDoc.SelectSet
 
    ' Get the selected curve from the select set.
    Dim oDrawCurveSeg As DrawingCurveSegment
    
    oDrawCurveSeg = ThisApplication.CommandManager.Pick _
     (Inventor.SelectionFilterEnum.
      kDrawingCurveSegmentFilter,
      "Select a drawingCurve")

    ' Get the parent DrawingCurve
    Dim oDrawCurve As DrawingCurve
    Try
    oDrawCurve = oDrawCurveSeg.Parent
    Catch ex As Exception
    Exit Sub
    End Try

    ' Get the model geometry this curve represents.
    Dim oModelGeom As Object
    oModelGeom = oDrawCurve.ModelGeometry
    


    ' Check to see if the returned object supports
    ' the ContainingOccurrence property.
    Dim oOcc As ComponentOccurrence
    'oOcc = oModelGeom.ContainingOccurrence
    
    Dim oModelGeometry =
        oDrawCurveSeg.Parent.ModelGeometry
    Dim oCompDef As ComponentDefinition
    

    Try
        
    oCompDef = oModelGeometry.parent.componentdefinition

    partName = oCompDef.Document.DisplayName
    
        oOcc = oModelGeom.ContainingOccurrence

        
        'Get the drawing view
        Dim oDrwView As DrawingView
        oDrwView = oDrawCurve.Parent
        
        
    Catch ex As Exception
           MessageBox.Show("Problem using part: " & partName, "iLogic")
        Exit Sub
    End Try


        'Dim oPart As String
        oPart = oCompDef.Document.DisplayName & ".ipt"
        Dim AutoType As String
        Dim uom as UnitsOfMeasure = oDoc.UnitsOfMeasure                                
        Dim oRB As Box
        Try
        oRB = oOcc.RangeBox
        Catch ex As Exception
        MessageBox.Show("error with dims", "iLogic")
        End Try
        Dim minp As point = oRB.minPoint
        Dim maxp As point = oRB.maxPoint
        Dim AutoName As String
        AutoName = "-"

        InventorVb.DocumentUpdate()
        
        Try
        oCheckFile = iProperties.Value(oPart, "Project", "Part Number")
        Catch
        MessageBox.Show("Error finding file for part: " & partName, "iLogic")
        Exit Sub
        End Try

        'Get part dimensions
        dp=0
        X = Round(uom.ConvertUnits ((maxP.X - minP.X), "cm", uom.LengthUnits), dp)
        Y = Round(uom.ConvertUnits ((maxP.Y - minP.Y), "cm", uom.LengthUnits), dp)
        Z = Round(uom.ConvertUnits ((maxP.Z - minP.Z), "cm", uom.LengthUnits), dp)
                'MessageBox.Show("Extents: " & X & " : " & Y & " : "  & Z, "iLogic")


        'order dimensions largest to smallest
        Thickness = MinOfMany(X, Y, Z)
        Length = MaxOfMany(X, Y, Z)
        Width = X
        If Thickness = X Or Length = X Then
            Width = Y
            If Thickness = Y Or Length = Y Then
            Width = Z
            End If
        End If
        
        'get mass prop for beams and channel
        StockNoPropLast = Right((iProperties.Value(oPart, "Project", "Stock Number")),   Len(iProperties.Value(oPart, "Project", "Stock Number"))-InStrRev(iProperties.Value(oPart, "Project", "Stock Number"), "x"))
        
        
        
        'get type
        Try
        AutoType = Parameter(oPart, "Type")
        Catch ex As Exception
        
            'Test parameters
            Try
            parametro = Parameter(oPart, "G_NG")
            G_NG = 1
            Catch
            G_NG = 0
            End Try
            
            Try
            parametro = Parameter(oPart, "G_T")
            G_T = 1
            Catch
            G_T = 0
            End Try
            
            Try
            parametro = Parameter(oPart, "G_W")
            G_W = 1
            Catch
            G_W = 0
            End Try
            
            Try
            parametro = Parameter(oPart, "G_ER")
            G_ER = 1
            Catch
            G_ER = 0
            End Try
            
            Try
            parametro = Parameter(oPart, "G_T1")
            G_T1 = 1
            Catch
            G_T1 = 0
            End Try
            
            If G_NG = 1 Then
            AutoType = "PFC"
            ElseIf G_T1 = 0 And G_W = 1 And G_ER = 0 And G_T = 1 Then
            AutoType = "RHS"
            ElseIf G_T = 1 And G_W = 0 Then
            AutoType = "CHS"
            ElseIf G_T = 0 And G_W = 0 Then
            AutoType = "RD BAR"    
            ElseIf G_T1 = 1 And G_NG = 0 Then
            AutoType = "UC"
            ElseIf G_ER = 1 Then
            AutoType = "RSA"
            ElseIf G_W = 1 And G_T = 0 Then
            AutoType = "F BAR"
            Else
            AutoType = ""
            End If
            
        End Try
        
        oType = InputBox("Treat as:", "Part Type", AutoType)
        
        
    
        'set default name
        Select Case UCase(oType)
        
        Case "PLATE"
        AutoName = "PLT " & Thickness & " THK " & Length & " x " & Width
        
        Case "F BAR"
        AutoName = "F/BAR " & Width & " x " & Thickness
        
        Case "CHS"
        Try 
        AutoName = "CHS " & Parameter(oPart, "G_H") & " OD x " & Parameter(oPart, "G_T") & " WT"
        Catch
        MessageBox.Show("Error getting parameters", "iLogic")
        AutoName = ""
        End Try
        
        Case "SHS", "RHS"
        Try
        If Parameter(oPart, "G_W") = Parameter(oPart, "G_H") Then
        AutoName = "SHS " & Parameter(oPart, "G_H") & " x " & Parameter(oPart, "G_W") & " x " & Parameter(oPart, "G_T")
        Else
        AutoName = "RHS " & Parameter(oPart, "G_H") & " x " & Parameter(oPart, "G_W") & " x " & Parameter(oPart, "G_T")
        End If
        Catch
        MessageBox.Show("Error getting parameters", "iLogic")
        AutoName = ""
        End Try
        
        Case "RD BAR"
        Try 
        AutoName = "RD BAR DIA. " & Parameter(oPart, "G_H")
        Catch
        MessageBox.Show("Error getting parameters", "iLogic")
        AutoName = ""
        End Try
        
        Case "RSA"
        Try 
        AutoName = "RSA " & Parameter(oPart, "G_H") & " x " & Parameter(oPart, "G_W") & " x " & Parameter(oPart, "G_T")
        Catch
        MessageBox.Show("Error getting parameters", "iLogic")
        AutoName = ""
        End Try
        
        Case "PFC"
        Try 
        AutoName = "PFC " & Parameter(oPart, "G_H") & " x " & Parameter(oPart, "G_W") & " x " & StockNoPropLast
        Catch
        MessageBox.Show("Error getting parameters", "iLogic")
        AutoName = ""
        End Try

        Case "UC"
        Try 
        AutoName = "UC " & Replace(iProperties.Value(oPart, "Project", "Stock Number"), "x", " x ")
        Catch
        MessageBox.Show("Error getting parameters", "iLogic")
        AutoName = ""
        End Try
        
        Case "UB"
        Try 
        AutoName = "UB " & Replace(iProperties.Value(oPart, "Project", "Stock Number"), "x", " x ")
        Catch
        MessageBox.Show("Error getting parameters", "iLogic")
        AutoName = ""
        End Try

        Case Else
        AutoName = ""
        End Select
        
        
        
        
        oNewDescription = InputBox("Description for '" & partName & "':", "Description Editor", AutoName)
        

        
        If oNewDescription = "" Then
        
        MessageBox.Show("Description change cancelled.", "iLogic")
        
        Else
        
        iProperties.Value(oPart, "Project", "Description") = oNewDescription
        InventorVb.DocumentUpdate()
        iLogicVb.RunRule("Dimensions - Individual")

        End If
        
                

 

A few notes:

  • Dimensions of non-content centre parts are aligned to the assembly's User Coordinate System, so tilted components will show incorrect extents. I'm currently working on this.
  • I'm no code expert and alot of this rule was stitched together from a large variety of sources. Code is quite untidy in places and probably does not use the most efficient methods.
  • Rule works by selecting a line from an assembly view. It doesn't currently work for part views unless they are part-isolated views from an assembly.

In saying that, this code has worked perfectly for me thus far, and is going to be a BIG time saver.

If you have any probs, let me know.