Yes the log message is a replacement for using a message box. It allows the user to get that information and store it and analyze what is happening, it simply means I don't need to click through 100's of message boxes in a for loop. There is likely an equivalent for your 2010 version which is
Trace.WriteLine
I would suggest get that up an running at some point make things easier.
https://adndevblog.typepad.com/manufacturing/2014/08/debug-ilogic.html
VBA has the same Debug.Print ("Hello") and shows up in the immediate window.
There really is no difference between the case and if statement method. Case will be faster overall and easier to write and follow in the long run.
I did see errors in the previous code when running the rule in the assembly that had read only parts. The ilogic snippet was erroring out when trying to check if the iproperty contained Joist, I guess it tries to gain access as if to write to the property. I used on error resume next as a test the loop worked and then said I would change the snippet to the full API method using property sets and this works fine.
https://knowledge.autodesk.com/search-result/caas/simplecontent/content/list-all-iproperties-and-how...
ilogic snippet:
iProperties.Value(oRefDoc.DisplayName,"Project", "Estimated Cost")
API Property Set:
Dim oPropertySet As PropertySet
oPropertySet = oRefDoc.PropertySets.Item("Inventor Document Summary Information")
oCategory = oPropertySet.Item("Category")
I eliminated any errors of parameters etc by commenting out that code and just see if the for loop and if statement can run without errors.
Sub Main
PJoist_UL = Price_per_ft_2x6_board_HD'Parameter from Assy,'Price of joist per foot
PDecking_UL = Price_per_sq_in_4x8_HD 'Parameter from Assy,'Price of joist per sq in
Dim oPrice As Double
' Get the active assembly.
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
' Get all of the referenced documents.
Dim oRefDocs As DocumentsEnumerator
oRefDocs = oAsmDoc.AllReferencedDocuments
' Iterate through the list of documents.
Dim oRefDoc As Document
'Loop through all referenced documents
For Each oRefDoc In oRefDocs
Dim oPropertySet As PropertySet
oPropertySet = oRefDoc.PropertySets.Item("Inventor Document Summary Information")
oCategory = oPropertySet.Item("Category")
'' 'Find the part by looking at category in each document using oRefDoc.DisplayName as the document reference
If oCategory.Value = "Joist" Then
MessageBox.Show("Message", "In Joist If Statement")
' Dim oG_L As Double
' oG_L = Parameter(oRefDoc.DisplayName, "G_L")
' 'Price Calculation
' oPrice = PJoist_UL * (oG_L / 12) ' with G_L in inches,
' 'Apply the pricing to each document
' If oPrice <> 0
' iProperties.Value(oRefDoc.DisplayName,"Project", "Estimated Cost") = oPrice
' End If
'Find the part by looking at category in each document using oRefDoc.DisplayName as the document reference
ElseIf oCategory.Value = "Decking" Then
MessageBox.Show("Message", "In Joist If Statement")
' Dim oLength,oWidth As Double
' oLength = Parameter(oRefDoc.DisplayName, "SheetMetalLength")
' oWidth = Parameter(oRefDoc.DisplayName, "SheetMetalWidth")
' oArea = oLength * oWidth
' 'Price Calculation
' oPrice = PDecking_UL * oArea ' with G_L in inches,
' 'Apply the pricing to each document
' If oPrice <> 0
' iProperties.Value(oRefDoc.DisplayName,"Project", "Estimated Cost") = oPrice
' End If
End If
Next
End Sub
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan