Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

ilogic to separate content center parts from modeled parts

Anonymous

ilogic to separate content center parts from modeled parts

Anonymous
Not applicable

I am creating a rule that takes part information (raw material part number and quantity from custom parameters) from the parts in my assemblies and exports them to a file that can be imported by our ERP system.

 

My code works but I would like to filter out the content center parts from the modeled parts - our content center parts are usually purchased and do not have a raw material part number.

 

an example of the code I am using that filters out parts in the assembly (to avoid sub assemblies and virtual parts):

 

SyntaxEditor Code Snippet

Dim oAsmDoc As AssemblyDocument
oAsmDoc
= ThisApplication.ActiveDocument
Dim oOcc As ComponentOccurrence

For Each oOcc In oAsmDoc.ComponentDefinition.Occurrences
If TypeOf oOcc.Definition Is PartComponentDefinition Then

MessageBox.Show(oOcc.Name, "Part Name")

Else
End If
Next

The above code works but does not filter out content center parts. Could someone please point me in the right direction to filter out content center parts from modeled parts?

 

Thanks!

0 Likes
Reply
509 Views
4 Replies
Replies (4)

MechMachineMan
Advisor
Advisor
Try gather part information using oDocument.AllReferencedDocuments

And then filter out content centre parts by a string comparison such as;

If oPart.FullFileName Like "*Content Center*"

or

If oPart.FullFileName Like oProjectManager.ContentCenterPath

Or something along those lines.

I can't really see much benefit to running through an assembly rather than using the documents UNLESS there are custom parts in parts lists or Virtual components that need to be exported for your ERP

--------------------------------------
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

Anonymous
Not applicable

Thanks for your reply, I'll explore that option.

 

The trouble is that the custom iproperty fields in content center parts do not exist like they do in our part templates, such as the raw material part number and quantity. I've tried to navigate around this issue with code like the following:

 

SyntaxEditor Code Snippet

For Each oOcc In Occurrences 
    If Not TypeOf oOcc.Definition Is AssemblyComponentDefinition Then
    
        ' Get the custom iproperty for the material part number
        If Not String.IsNullOrEmpty(iProperties.Value("Custom", "Mtl Part Number")) Then
            PartNumber = iProperties.Value("Custom", "Mtl Part Number") 
            Else
            Continue For
        End If

.
.
.
End If
Next

Which would essentially filter out content center parts because they do not contain these custom iproperty fields but the above code does not work, it gives the error:

 

iProperties: Cannot find a property named "Mtl Part Number".

0 Likes

MechMachineMan
Advisor
Advisor
Put the call to the Custom iProperty within a Try Catch so that it will
resume when it come across content center parts.

--------------------------------------
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

RoyWickrama_RWEI
Advisor
Advisor

I have been trying hard to get the content center components filtered out from the model parts. Your suggestion could be good. However, I can't get it. Could you elaborate your solution, please.

 

Thanks a lot

0 Likes