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.
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!
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.
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?
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.
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?
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
Can't find what you're looking for? Ask the community or share your knowledge.