BOM structure (Normal,Phantom,etc) to custom iProperties

BOM structure (Normal,Phantom,etc) to custom iProperties

Anonymous
Not applicable
2,594 Views
6 Replies
Message 1 of 7

BOM structure (Normal,Phantom,etc) to custom iProperties

Anonymous
Not applicable

Hi,

 

What I want in the assembly is getting the BOM structure (Normal,Phantom,etc) as property in an custom iProperty field of the part.

 

Once as custom iProperty I can communicate it with an PLM program.

 

 

Is this possible? any ideas?

 

 

Thank you in advanched,

 

 

Bas

0 Likes
Accepted solutions (1)
2,595 Views
6 Replies
Replies (6)
Message 2 of 7

MechMachineMan
Advisor
Advisor

Run this as a rule from the top level assembly.

 

Sub Main()
    Dim oDoc As Document = ThisDoc.Document
    PushBOMStructToiProp(oDoc)

    Dim oSubDoc As Document
    For Each oSubDoc in oDoc.AllReferencedDocuments
        PushBOMStructToiProp(oSubDoc)
    Next
    MsgBox("Rule Complete!')
End Sub

Sub PushBOMStructToiProp(oSubDoc As Document)
        Select Case oSubDoc.ComponentDefinition.BOMStructure
            Case 51974
                oBOMStruct = "INSEPARABLE"
             Case 51970
                oBOMStruct = "NORMAL"
            Case 51971
                oBOMStruct = "PHANTOM"
            Case 51973
                oBOMStruct = "PURCHASED"
            Case 51972
                oBOMStruct = "REFERENCE"
            Case Else
                 MsgBox("Error fetching BOM structure to iProp for:" & vblf & oSubDoc.FullFileName)
          End Select

    Try     
     iProperties.Value(System.IO.Path.GetFileName(oSubDoc.FullFileName), "Custom", "BOMStruct") 
    Catch
         MsgBox("Error pushing BOM Structure to iProp for: " & vblf & oSubDoc.FullFileName)
    End try   
End Sub

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 7

Anonymous
Not applicable

Thanks for posting your solution, but this dialog message below i get. ?

 

 

---------------------------
Rule Compile Errors in BOM Structure to custom iProperties
---------------------------
Error in rule program format: The rule must contain:
Sub Main()
...
End Sub
---------------------------
OK
---------------------------

 

 

Please let me know..

 

 

0 Likes
Message 4 of 7

MechMachineMan
Advisor
Advisor

If you are planning on playing with iLogic/API you REALLY need to do some study and learning as to how basic programming and debugging works....

 

The code had a single quote where there should have been a double quote. Very obvious to anyone who understands anything about syntax...

 

Sub Main()
    Dim oDoc As Document = ThisDoc.Document
    PushBOMStructToiProp(oDoc)

    Dim oSubDoc As Document
    For Each oSubDoc in oDoc.AllReferencedDocuments
        PushBOMStructToiProp(oSubDoc)
    Next
    MsgBox("Rule Complete!")
End Sub

Sub PushBOMStructToiProp(oSubDoc As Document)
        Select Case oSubDoc.ComponentDefinition.BOMStructure
            Case 51974
                oBOMStruct = "INSEPARABLE"
             Case 51970
                oBOMStruct = "NORMAL"
            Case 51971
                oBOMStruct = "PHANTOM"
            Case 51973
                oBOMStruct = "PURCHASED"
            Case 51972
                oBOMStruct = "REFERENCE"
            Case Else
                 MsgBox("Error fetching BOM structure to iProp for:" & vblf & oSubDoc.FullFileName)
          End Select

    Try     
     iProperties.Value(System.IO.Path.GetFileName(oSubDoc.FullFileName), "Custom", "BOMStruct") 
    Catch
         MsgBox("Error pushing BOM Structure to iProp for: " & vblf & oSubDoc.FullFileName)
    End try   
End Sub

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 5 of 7

Anonymous
Not applicable

@MechMachineMan

 

Yesterday I discovered as a "beginner" what was missing as a rule....

 

     iProperties.Value(System.IO.Path.GetFileName(oSubDoc.FullFileName), "Custom", "BOMStruct") 

I have adapted this and it works as requested. ie. I learn the basis by asking and doing.
thanks for your help! 

 

 

 

Bas

 

0 Likes
Message 6 of 7

Anonymous
Not applicable
Accepted solution

@MechMachineMan wrote:

If you are planning on playing with iLogic/API you REALLY need to do some study and learning as to how basic programming and debugging works....

 

The code had a single quote where there should have been a double quote. Very obvious to anyone who understands anything about syntax...

 

Sub Main()
    Dim oDoc As Document = ThisDoc.Document
    PushBOMStructToiProp(oDoc)

    Dim oSubDoc As Document
    For Each oSubDoc in oDoc.AllReferencedDocuments
        PushBOMStructToiProp(oSubDoc)
    Next
    MsgBox("Rule Complete!")
End Sub

Sub PushBOMStructToiProp(oSubDoc As Document)
        Select Case oSubDoc.ComponentDefinition.BOMStructure
            Case 51974
                oBOMStruct = "INSEPARABLE"
             Case 51970
                oBOMStruct = "NORMAL"
            Case 51971
                oBOMStruct = "PHANTOM"
            Case 51973
                oBOMStruct = "PURCHASED"
            Case 51972
                oBOMStruct = "REFERENCE"
            Case Else
                 MsgBox("Error fetching BOM structure to iProp for:" & vblf & oSubDoc.FullFileName)
          End Select

    Try     
     iProperties.Value(System.IO.Path.GetFileName(oSubDoc.FullFileName), "Custom", "BOMStruct") = oBOMStruct
    Catch
         MsgBox("Error pushing BOM Structure to iProp for: " & vblf & oSubDoc.FullFileName)
    End try   
End Sub

 

 

what I meant yesterday... I added         = oBOMStruct    to rule Try....

 

Now it's working correct

 

 

Grtz

 

Message 7 of 7

pst!
Enthusiast
Enthusiast

Thank you for your great work. This is exactly what we need.
For us, the script stops for some assemblies with the message "Member not found".

Do you have an idea how to rule out this bug so that the script still runs?
Unfortunately I can not program myself 😞

Thank you for your answer

0 Likes