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
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
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.
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
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.
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
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.
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
' 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
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
hi!
It's possible to have a rule how take a total square feet of each material in partlist?
Thanks for your help!
If you can break the process into an easy, logical procedure, chances are like 95% that you can do it with code.
It's just a matter of finding the necessary resources and learning the programming language to implement it.
Some resources for anyone wanting to learn more:
Google: "msdn + vb.net + ________"
API Reference: C:\Program Files\Autodesk\Inventor 2016\Local Help\admapi_20_0.chm
Blog: http://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html
Blog: http://beinginventive.typepad.com/being-inventive/
Blog: http://adndevblog.typepad.com/manufacturing/
Blog: http://modthemachine.typepad.com/my_weblog/
Autodesk Developer Network Github: https://github.com/ADN-DevTech/Inventor-Training-Material
Good luck!
Hi Curtise;
Although this is an old posting, I found it useful (or learnt from your coding) to find the total weight as per the BOM in the drawing. Shown below is the generic coding (user needs to input for the QTY and Weight column number in BOM and units of weight as well) I developed.
' 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. oCol_Qty = InputBox("COLUMN NUMBER FOR QTY PER ASS'Y: ", "COLUMN NUMBER: QTY", "Column Number - QTY") oCol_WT = InputBox("COLUMN NUMBER FOR WEIGHT: ", "COLUMN NUMBER: WEIGHT", "Column Number - WT") Dim oWT_Units_Array As New ArrayList oLBS = "LBS" oKG = "Kg" 'get the materials collection 'get the desired material from the collection oWT_Units_Array.add(oLBS) oWT_Units_Array.add(oKG) oWT_LBS_Kg = InputListBox("SELECT FROM ABOVE!", oWT_Units_Array, oWT_Units_Array.Item(0), "WT: LBS OR Kg", "WEIGHT UNITS") WT_Total = 0 Dim i As Long For i = 1 To oPartList.PartsListRows.Count oCell_UWT = oPartList.PartsListRows.Item(i).Item(Val(oCol_Qty)).Value oCell_QTY = oPartList.PartsListRows.Item(i).Item(Val(oCol_WT)).Value WT_ithRow = Val(oCell_UWT)*Val(oCell_QTY) WT_Total = WT_Total + WT_ithRow 'MessageBox.Show("ROW NUMBER: " & i _ '& vbLf & "oCell_UWT: " & oCell_UWT _ '& vbLf & "oCell_QTY: " & oCell_QTY _ '& vbLf & "WT_ithRow: " & WT_ithRow _ '& vbLf & "WT_Total: " & WT_Total, "Title") Next 'MessageBox.Show("oPartList.PartsListRows.Count: " & oPartList.PartsListRows.Count, "Title") iProperties.Value("Custom", "WEIGHT") = CStr(WT_Total) & " " & oWT_LBS_Kg iLogicVb.UpdateWhenDone = True
I believe, by now, you may have a better idea for this purpose.
I request you reply me with comments. You are busy - take your time.
If you're just wanting to get the mass from the assembly, you can access that information more directly as in this example:
'get the document from the first 'drawing view Dim oMdoc As Document oMdoc = ThisDrawing.ModelDocument ' Get the mass Dim dMass As Double dMass = oMdoc.ComponentDefinition.MassProperties.Mass ' Get the UnitsOfMeasure object Dim oUOM As UnitsOfMeasure oUOM = oMdoc.UnitsOfMeasure 'Convert the mass to the current document units Dim sMass As String sMass = oUOM.GetStringFromValue(dMass, oUOM.GetStringFromType(oUOM.MassUnits)) 'get the units string sUnit = oUOM.GetStringFromType(oUOM.MassUnits) 'Format Units String If sUnit = "lbmass" Then sMass = Replace(sMass, "lbmass", "LBS") Else If sUnit = "kg" Then sMass = Replace(sMass, "kg", "Kg") End If MessageBox.Show("Total Weight: " & sMass, "iLogic") iProperties.Value("Custom", "WEIGHT") = sMass iLogicVb.UpdateWhenDone = True
However, if there truly is a need to read the information from the parts list here is another example that is similar to the one you posted:
' 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) 'get the column titles/headers Dim oHeaderList As New ArrayList For i = 1 To oPartList.PartsListColumns.Count oTitle = oPartList.PartsListColumns.Item(i).Title oHeaderList.add(oTitle) Next 'get user input oCol_Qty = InputListBox("Select the QTY column", _ oHeaderList, oHeaderList.Item(0), "iLogic", "Column Titles:") oCol_WT = InputListBox("Select the WEIGHT column", _ oHeaderList, oHeaderList.Item(0), "iLogic", "Column Titles:") bUnit = InputRadioBox("Select unit", "LBS", "Kg", True, "iLogic") 'evaluate user input for unit 'and set string If bUnit = True Then bUnit = "LBS" Else bUnit = "Kg" End If 'multiply the QTY by Weight for each row 'add add values for total WT_Total = 0 For i = 1 To oPartList.PartsListRows.Count oCell_QTY = oPartList.PartsListRows.Item(i).Item(oCol_Qty).Value oCell_UWT = oPartList.PartsListRows.Item(i).Item(oCol_WT).Value WT_ithRow = Val(oCell_UWT)* Val(oCell_QTY) WT_Total = WT_Total + WT_ithRow Next MessageBox.Show("Total Weight: " & WT_Total & " " & bUnit, "iLogic") iProperties.Value("Custom", "WEIGHT") = CStr(WT_Total) & " " & oWT_LBS_Kg iLogicVb.UpdateWhenDone = True
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Thanks a lot for taking time to reply to my request: it is not only the solution but also some kind of information useful in my ILogic pursuits.