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

    Autodesk Inventor

    Reply
    Contributor
    Posts: 18
    Registered: ‎08-06-2012
    Accepted Solution

    iLogic Rule to Print String to Parts List

    306 Views, 7 Replies
    03-05-2013 10:10 AM

    Hello,

    I am trying to make an iLogic rule that gets mutliple strings from different places, and prints them to a user property in the Parts List.

    My ultimate goal is to print the drawing number, sheet number and the item column value to the user property with the format being...

    "XXXXX-X-X"

    So far, i can get the drawing number from an iProperty and the sheet number easily. But im getting stumped on obtaining the item coloum value and printing it to the same row.

    This is what i have so far...

     

    Dim DWGNUM As String = iProperties.Value("custom", "DWG Number")
    SheetNumber = Mid(ThisDoc.Document.ActiveSheet.Name, InStr(1, ThisDoc.Document.ActiveSheet.Name, ":") + 1)
    MessageBox.Show(DWGNUM+"-"+SheetNumber, "DXF Number")

     

    And print the message box output to a column in the parts list

    Any help is appreciated!

    Thanks in advanced

    Please use plain text.
    New Member
    Posts: 1
    Registered: ‎03-06-2013

    Re: iLogic Rule to Print String to Parts List

    03-06-2013 09:33 AM in reply to: TomTom111

    Hey everyone, I work with Thomas and have been assisting where i can on the iLogic rule, we have been able to generate the "dxf" number for each row now, dxf number being "Drawing Number - Sheet Number - Item Number"

    ex: 123456-7-8. What we would like it to do now is reference/scan our custom iProperty column called "Overall Dim" wich gives us the length of a structual component (10 1/4") or the overall length and width of a sheetmetal component (15 1/8" x 32 1/2"). Our goal is for the iLogic rule to recognize wether or not the "x" is present or not and only generate a dxf for those rows with the x. and then ultimately write that information in our custom DXF No column.

    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,950
    Registered: ‎03-08-2006

    Re: iLogic Rule to Print String to Parts List

    03-06-2013 03:13 PM in reply to: cmt-edgar

    Hi cmt-edgar,

    Here's a quick example of using the String.Contains method to do this.

     

    Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
    http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

     

    I hope this helps.
    Best of luck to you in all of your Inventor pursuits,
    Curtis
    http://inventortrenches.blogspot.com

     

    s1 =  iProperties.Value("Custom", "Overall Dim")
    Dim s2 As String = "x" 
    Dim b As Boolean
    b = s1.Contains(s2)
    If b = True Then
    MessageBox.Show(s1 & " does contain: " & s2, "iLogic")
    Else
    MessageBox.Show(s1 & " does NOT contain: " & s2, "iLogic")
    End if

     



      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
    Posts: 18
    Registered: ‎08-06-2012

    Re: iLogic Rule to Print String to Parts List

    03-07-2013 08:37 AM in reply to: Curtis_Waguespack

    Thanks Curtis!

    This will definitely help.

     

    Is there a way to use the String.Contains method to check a column of the Parts List in the current drawing?

    We want to check if a specific cell of the Parts List has an "x", and if it does, we want to write the "dxf" number (Drawing Number - Sheet Number - Item Number) to a cell in the same row as the number tested.

    The cell that will contain the DXF number is a user property in the parts list.

     

    Thanks for the help.

    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,950
    Registered: ‎03-08-2006

    Re: iLogic Rule to Print String to Parts List

    03-07-2013 09:07 AM in reply to: TomTom111

    Hi TomTom111,

     

    Here's a quick ilogic example that iterates through the parts list and reads each cell. I'm not sure how you plan tol identify the specific cell to look at so I didn't really look into targeting a specific cell. But hopefully you can use it to work up a solution with the previous example, if not post back and I'll have another look.

     

    I hope this helps.
    Best of luck to you in all of your Inventor pursuits,
    Curtis
    http://inventortrenches.blogspot.com

     

     

        ' Set a reference to the drawing document.
        ' This assumes a drawing document is active.
        Dim oDrawDoc As DrawingDocument
        oDrawDoc = ThisApplication.ActiveDocument
        
        ' Set a reference to the first parts list on the active sheet.
        ' This assumes that a parts list is on the active sheet.
        Dim oPartList As PartsList
        oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
        
        ' Iterate through the contents of the parts list.
        Dim i As Long
        For i = 1 To oPartList.PartsListRows.Count
            ' Get the current row.
            Dim oRow As PartsListRow
            oRow = oPartList.PartsListRows.Item(i)
            
           ' Iterate through each column in the row.
            Dim j As Long
            For j = 1 To oPartList.PartsListColumns.Count
                ' Get the current cell.
                Dim oCell As PartsListCell
                oCell = oRow.Item(j)
                
              'Display the value of the current cell.
               sCell = "Row: " & i & vblf & oPartList.PartsListColumns.Item(j).Title & " = "& oCell.Value
    	Dim Result = MessageBox.Show( sCell , "iLogic",MessageBoxButtons.OKCancel)
    	If Result = DialogResult.Cancel Then
    	Return
    	Else 
    	End If
    
            Next
        Next

     



      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
    Posts: 18
    Registered: ‎08-06-2012

    Re: iLogic Rule to Print String to Parts List

    03-07-2013 11:36 AM in reply to: Curtis_Waguespack

    Thank you Curtis,

    your expertise has been most helpful.

    So now i can show only the values of a certain coloum.

    Hopefully, my final question would be-

    Can you change the value of a cell in the Parts List with an iLogic rule, or are the cells of the Parts List 'Read Only'?

    If you can, what is the code for that?

    Say the parts list cell is blank, and you want to wrint a string of text to it.

    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,950
    Registered: ‎03-08-2006

    Re: iLogic Rule to Print String to Parts List

    03-07-2013 01:10 PM in reply to: TomTom111

    Hi TomTom111,

     

    Here's a quick example that looks for a part number and then writes to the description column of that row if the part number matches.

     

    I hope this helps.
    Best of luck to you in all of your Inventor pursuits,
    Curtis
    http://inventortrenches.blogspot.com

     

    Autodesk Inventor Write to Parts List iLogic.png

     

    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument
        
    ' Set a reference to the first parts list on the active sheet.
    ' This assumes that a parts list is on the active sheet.
    Dim oPartList As PartsList
    oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
       
    ' Iterate through the contents of the parts list.
    Dim i As Long
    For i = 1 To oPartList.PartsListRows.Count
    'look at only the part number column
    oCell  = oPartList.PartsListRows.Item(i).Item("PART NUMBER")
    	'find a specific part number
    	If oCell.Value = "12-345" Then 
    	'identify the cell in the description column for the row that 
    	'the part number was found in
    	oCell2 = oPartList.PartsListRows.Item(i).Item("DESCRIPTION")
    	'write to the target cell
    	oCell2.Value = "Bingo!" 
    	End if
    Next

     

     



      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
    Posts: 18
    Registered: ‎08-06-2012

    Re: iLogic Rule to Print String to Parts List

    03-07-2013 01:29 PM in reply to: Curtis_Waguespack

    This works great!

    Thank you for your time in helping me along with this!

    *Expert_Elite* for a reason apparently.

     

    P.S.

    Your blog is also of much help.

    Thanks much

    Please use plain text.