Please I need help!
What to put in the "Model Data"?
Thanks!
quantity = ThisBOM.CalculateQuantity("Model Data", 06.06.0001.02.0001:1)
Solved! Go to Solution.
Solved by ivanildo.b. Go to Solution.
Hi @ivanildo.b. The online help page says that is supposed to be where you input the name of the BOMView you want to process, and it should be the 'Model' one. Below is the link to the online help page for that method.
ICadBom.CalculateQuantity Method
Wesley Crihfield
(Not an Autodesk Employee)
Thanks for the answer.
Please use the attached files for an example.
That way I can understand.
Hi @ivanildo.b. Sorry for the confusion. I am still using 2022.4 at work, so when I open your files, they are similar to imported models, with no history, and not as fully functional as native ones for me. I did a little testing with a 2022 version assembly file of my own, to test that iLogic shortcut snippet you were trying to use. Apparently there are two acceptable names for the 'Model' tab/view (BOMView) in that snippet. You can either use "Unnamed" or "Model Data", because that BOMView API object has not been given a meaningful name like the other two have. Also, I don't know why neither of us has seen this yet, but the second 'input' you are using is not enclosed in quotation marks, which is likely the main reason it was not working for you. Both inputs should be a String (quoted text, or a String Type variable that has been assigned a value).
By the way, below is a simple iLogic rule you can use to explore the names of all three possible BOMViews.
Dim oADoc As AssemblyDocument = ThisDoc.Document Dim oBOM As BOM = oADoc.ComponentDefinition.BOM oBOM.PartsOnlyViewEnabled = True oBOM.StructuredViewEnabled = True Dim oBOMViews As BOMViews = oBOM.BOMViews 'Dim oModelBOMView As BOMView = oBOMViews.Item("Unnamed") 'MsgBox("oModelBOMView.Name = " & oModelBOMView.Name & vbCrLf & _ '"oModelBOMView.ViewType.ToString = " & oModelBOMView.ViewType.ToString,,"") For Each oBOMView As BOMView In oBOMViews MsgBox("oBOMView.Name = " & oBOMView.Name & vbCrLf & _ "oBOMView.ViewType.ToString = " & oBOMView.ViewType.ToString,,"") Next
Wesley Crihfield
(Not an Autodesk Employee)
Thank you for your attention to the previously sent reply,
I was trying to solve the problem in the face of the response obtained.
I did not succeed.
Is this example sent possible to explain by these files?
I want to apply this rule to projects I'm developing.
Thanks!
Hi @ivanildo.b. When using that iLogic shortcut snippet you were trying to use, is sounds like the first value it wants you to specify must always be the specific String type value "Model Data". Then it sounds like the second value it wants you to specify is the 'Part Number' iProperty value of the document in the BOM that you want to calculate the quantity of. The value of the Part Number iProperty is always a String type value. With these facts in mind, it looks the code you posted already had the correct first input value, but the second input value was not correct. The second input value in the code you posted appears to not be quoted, which is its first problem, then it also appears to be the name of an assembly component, because it has the ":1" at the end of it. It does not want the name of an assembly component there, it wants the value of that document's Part Number iProperty, and that value must either be within quotes, or you must assign the value to a String type variable before that point, then include that variable in that second position.
I will attempt to show you the difference & changes that must be made below.
In this example code below, I am first attempting to get the value of the Part Number iProperty from the assembly component that you named in your code above. Then I am supplying that value to the method (CalculateQuantity) you are using, as its second input value.
Dim sPN As String = iProperties.Value("06.06.0001.02.0001:1","Project", "Part Number")
quantity = ThisBOM.CalculateQuantity("Model Data", sPN)
If you already know the value of that component's Part Number iProperty, then you can skip retrieving that value from the component, and just enter it directly as the second input of the CalculateQuantity method, within quotation marks. If that still does not work for you, then I do not know another way to help, because I can not open your file, fix it, then re-attach it, because I am using a previous version of Inventor.
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.