Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

External Rule runs abnormally

5 REPLIES 5
Reply
Message 1 of 6
swalroth8KYHK
353 Views, 5 Replies

External Rule runs abnormally

I wrote a quick External Rule that would truncate the first ten digits from the default file name in the Assembly Browser.

 

It seemed to work perfectly for a time, but now it's renaming all parts as they are entered (I only want it run in specific assemblies) and not even uniformly at that.

 

ExternalRuleError.jpg

 

 

Each part file is a unique part with a unique name, but some of them are coming in as multiple instances with the same name, others are being renamed correctly. and its firing immediately without the msgBox appearing.

 

The code is below:

 

 

Sub Main()

Dim CNC as Integer

CNC = MsgBox("Drawing for CNC?", vbYesNo + vbQuestion, "For CNC")

If CNC = vbYes Then

Dim Path As String = ThisDoc.Path & "\"

InvDoc = ThisDoc.Document
Dim pCab As DocumentsEnumerator = InvDoc.AllReferencedDocuments
Dim sCab As Document

Dim oName As String
Dim nName As String

Dim nStart As Short
Dim nEnd As Short

For Each sCab In pCab

oName = sCab.DisplayName
nStart = 10
nEnd = Len(oName) - nStart

If nEnd >= 8

nName = oName.Substring(nStart,nEnd)
sCab.DisplayName = nName

End If

Next

Else

Exit Sub

End If

End Sub

 

Any help would be appreciated, thank you!

5 REPLIES 5
Message 2 of 6

1. Display Name and Browser Node label are two very different things

 

2. If changing the Browser node label, you need to be concerned with the ":#" portion as you can't have a duplicate name.

 

3. Updating the display name does not necessarily update the browser name.


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

1. I'm not sure which I need to change so it transfers correctly to Solid-CIM. Where and how are those two properties stored?

 

2. Each part has a unique name to begin with so there should never be multiple instances of a name.

 

3. So if Browser Node Label is the "correct" way to rename my parts, how do I do that in an iLogic Rule?

 

4. Is there a way to prevent my External Rules from seemingly running automatically?

Message 4 of 6

1. I'm not sure which I need to change so it transfers correctly to Solid-CIM. Where and how are those two properties stored?

 

A good starting point is probably finding this out. 

 

There is a display name field in the part's iProperties. There is an occurrence name in the occurences 'iProperties'. You could do some testing to see what your next phase needs.

 

2. Each part has a unique name to begin with so there should never be multiple instances of a name.

 

If you double click a name in the browser and name it something, then name the next node the same thing, you will get a "Name already in use" error.

 

3. So if Browser Node Label is the "correct" way to rename my parts, how do I do that in an iLogic Rule?

 

It's not necessarily the correct name. It defends on your needs. 

BrowserNodeDefinition and either label or some other property is what controls it. Should be easy enough to check with the object browser in VBA.

 

4. Is there a way to prevent my External Rules from seemingly running automatically?

 

In the rule window, make sure the settings aren't selected for "run automatically". Also ensure the rule isn't connected to any event triggers.


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

I am unable to find any code relating to changing a parts Browser Node Label, I keep getting errors saying its not for PartDocuments.

 

Also, I can't seem to get the box for Don't run automatically to stay checked. Is there something I need to add to the .txt file to set this?

Message 6 of 6

A quick search of Autodesk's nicely provided online reference material...

 

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-70282D24-D08A-4EA4-9BEA-56B87826573F


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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report