- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'd like to know how to force-rename bodies of multi-body part.
For example: there is a simplest multi-body part with three bodies named in index-style : "1" (Red), "2" (Green) and "3" (Blue).
For some reason I ask user to choose the body which he wants to be The Base body (#1).
Let say user points to Blue or Green body.
My code then try to set name "1" for it but the command mutually fails and name value doesn't change (I believe this happens because body names should be unique and there is already Red body named "1").
I'm looking for the way to smart-"swap" names in the described scenario.
I.e.: If name of the user-chosen body differs from "1" it's name backups to some string variable, then its name temporarily changes to something random (with no chances to match name of any existing bodies which is highly important in context of possible consequent runs of the script), then name of the Red body changes to the name of user-chosen body and finally user-chosen body gets it's brave-New name "1".
This sounds easy-peasy but till now I don't even invent the bullet-prove solution for that temporary random name.
Any ideas?
I'm using iLogic and my code for now is:
Dim oIPT As PartDocument = ThisDoc.Document
Dim oPCD As ComponentDefinition = oIPT.ComponentDefinition
Dim oB1 As SurfaceBody=ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Pick which body is the First one")
Dim InitName As String = oB1.Name
Dim NewName As String = InputBox ("Type new name for the selected body :", "New Name of the body", "1")
oB1.Name=NewName
MsgBox ("Initial body's name was - " & InitName & vbCrLF & vbCrLF & "New body's name is - " & oB1.Name,,"Rename result")
Please vote for Inventor-Idea Text Search within Option Names
Solved! Go to Solution.