Using part of file name as iProperty for BOM

Using part of file name as iProperty for BOM

Anonymous
Not applicable
1,353 Views
6 Replies
Message 1 of 7

Using part of file name as iProperty for BOM

Anonymous
Not applicable

Currently I am in a process of partly automating some aspects of 2D drawing at work. 

One of the points of interest is the BOM. 

 

We use file names structured as: [part number] [description] [rev. date].

Currently we have to manually add the iProperty 'PART NUMBER' and value for the BOM creation to work, but I'm really looking to automate this. 

 

What I'm trying to archive is the following (3D level); 

When a part/assembly is saved a check is performed if the iProperty 'PART NUMBER' exist, and if the value is equal to the first 10 characters of the file name. 

If not a popup gives the user the ability to automatically create/change this to match the first 10 characters.

This way backwards compatibility is granted as well as the opportunity to work with parts that don't have a number. 

 

The problem is that I am a complete rookie at programming iLogic rules so I am really hoping someone can help me out a bit. 

Thanks in advance!

0 Likes
1,354 Views
6 Replies
Replies (6)
Message 2 of 7

Rob67ert
Collaborator
Collaborator
Hoi Remco,

Welkom op dit forum.

What do you have till now?
Can you post the code you already have?
Robert

If you find this reply helpful ? It would be nice if you use the Accept as Solution or Kudos button below.
0 Likes
Message 3 of 7

Anonymous
Not applicable

You can do this two ways:

  1. Create a rule that will run from top level assembly and perform the check on all sub parts/assemblies
  2. Create a rule inside every part/assembly that performs the check on saving

Which do you prefer?

0 Likes
Message 4 of 7

Anonymous
Not applicable

This code will work for the second method. Create it inside each part/assemly

 

fname = ThisDoc.FileName(False) 'without extension
If iProperties.Value("Project", "Part Number") <> Left((fname),10) Then
	question = MessageBox.Show("Do you want to set Part Number to equal first 10 characters of filename?", fname & " Part Number Change",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
	If question = vbYes Then
		iProperties.Value("Project", "Part Number") = Left((fname),10)
	End If
End If

 To run the rule while saving the document, go to the event triggers (Manage > iLogic > Event Triggers) and add the above rule to the 'Before Save Document' trigger.

Event trigger.JPG

 

0 Likes
Message 5 of 7

MechMachineMan
Advisor
Advisor

You forgot this option:

 

3) Implement a pre-written add-in that ships with the Inventor install files. Modify it so that it runs your rule to check file names based on document save. 

 

This method makes it so you just have to upkeep/change code in one location instead of EVERY SINGLE FILE in the case that something changes.


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

Anonymous
Not applicable

@MechMachineMan I didn't know you could do that!

Would be useful for me learn how to do it. Could you provide a link to a help guide?

Thanks!

0 Likes
Message 7 of 7

MechMachineMan
Advisor
Advisor

From my posts in different threads:

 

https://forums.autodesk.com/t5/inventor-customization/run-external-ilogic-on-event/m-p/6963619/highl...

https://forums.autodesk.com/t5/inventor-customization/creating-a-addin-file-as-per-devtools-sample/m...

https://forums.autodesk.com/t5/inventor-customization/run-rule-on-application-event-add-in/m-p/67459...

 

"

Step 1: Install the devtools.msi that comes in the SDK with inventor.

Step 2: Find "VBAAutoMacro" sample.

Step 3: Open the sample and read the readme.

Step 4: Follow the instruction in the readme. Very simple. (to create the .addin file, just make a txt with the exact text in it, then rename the file to .addin).

Step 5: Open Inventor and reap the rewards.

Step 6: Write a macro to run on startup that enables event tracking in inventor

Step 7: Write the macro that catches the even and runs an iLogic rule.

Step 8: Implement them all properly.

Step 9: Profit.

"


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