Rename shrinkwrap multibodies.

Rename shrinkwrap multibodies.

aurel_e
Collaborator Collaborator
808 Views
2 Replies
Message 1 of 3

Rename shrinkwrap multibodies.

aurel_e
Collaborator
Collaborator

Hi all,

in the case of an ipt derived from an assembly using shrinkwrap command:

Using ilogic is there any chance to rename the bodies based on the original part name?

In my case the Solid2 will be renamed "Spacer-1", the Solid6->"Base block-1", Solid7->"Spacer-2"....

2020-04-28 11_02_19-Window.png

0 Likes
Accepted solutions (1)
809 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

Try this iLogic code.  It might be a bit hard to follow, but it works for similar situations on my end.

I'll try to explain the main points.

This is obviously using the Browser nodes instead of attempting to back-track through however many reference levels there may be to get the part.  (The part may have been a sub-part of a sub-assembly of the assembly you shrink wrapped to create this part file.)

The Solid Bodies folder is always the 3rd Node under the TopNode of the Model Browser pane.

The "FullPath" property of a Node is a string that includes every node name from the TopNode, down to the current Node, with colons ":" between each name.

The Split function splits a long String into an array of sub-strings by specifying what character is the "separator".

This process is necessary to separate the levels of the path, and to separate the levels of the assembly names that this part may have been inside of, and so separate the integer at the end.

The Replace function was used to get rid of the file extension of the final part name.

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Part Documents.",vbOK, "WRONG DOCUMENT TYPE")
	Return
End If

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPane As BrowserPane = oDoc.BrowserPanes.Item("Model")
Dim oSBodies As BrowserNode = oPane.TopNode.BrowserNodes.Item(3)
Dim oNode As BrowserNode
Dim oBody As SurfaceBody
Dim oFullPath As String
Dim oPName As String
Dim oIndex As String
Dim oNewName As String
For Each oNode In oSBodies.BrowserNodes
	oBody = oNode.NativeObject
	oFullPath = oNode.BrowserNodes.Item(1).FullPath
	oPName = Split(oFullPath, ":")(Split(oFullPath, ":").Length - 2)
	oIndex = Split(oFullPath,":")(Split(oFullPath,":").Length-1)
	oNewName = Replace(oPName,".ipt","") & "-" & oIndex
	oBody.Name = oNewName
Next

 

 

I hope this helps.
If this solves your problem, or answers your questions, please click 'Accept As Solution".
Or, if this helps you reach your goal, please click 'LIKES" 👍.

 

Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.
If you agree with any of them, please vote for them.

  • Add more capabilities to the 'Customize' dialog box (exe. Add Tab & Add Panel) Click Here
  • Constrain & Dimension Images In Assembly Sketches & Drawing Sketches (TitleBlocks & SketchedSymbols) Click Here
  • Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) Click Here
  • Add SolidBodies Folder In iLogic Rule Editor Model Tab Click Here
  • Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder Click Here
  • SetDesignViewRepresentation - Fix limitations for DrawingView of a Part Click Here
  • Create DocumentSubTypeEnum Click Here
  • Add kRevisionTag or kDrawingRevisionTag to ObjectTypeEnum Click Here

Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3

aurel_e
Collaborator
Collaborator

It works! Thank you.

I had to change the browser node to 2 (it was 3).

Dim oSBodies As BrowserNode = oPane.TopNode.BrowserNodes.Item(2)

 

0 Likes