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: 

Multi bodies - auto rename.

36 REPLIES 36
SOLVED
Reply
Message 1 of 37
Anonymous
6209 Views, 36 Replies

Multi bodies - auto rename.

Hello everybody,

 

I have small problem. I have lot of bodies (50) with name solid1.... solid50.

How can I quickly rename all bodies according some template for example "Plate_01... Plate_50"?

It is possible to use ilogic? or maybe will be better to use vba.

 

Somebody have idea??

 

Thank you for helps,

TJ

Tags (3)
36 REPLIES 36
Message 2 of 37
PACDrafting
in reply to: Anonymous

We use multi body part modeling also for platework.
I have had to write some code and procedures to get: thickness, width and length parameters from the solid body part file to each individual part file.
The trick is to make components into sheet metal part files then flat pattern all files.
My code does all this.
I'm not at work for a couple of weeks but I've bookmarked your question when I return.
In regards to the file naming. We have vault collaboration which auto names the files.
Message 3 of 37
Anonymous
in reply to: PACDrafting

hey friend i'm new at inventor and posting for help, and old with autocad , this sounds like just what I need, if you could help me too

                                                                                   thanks a lot

Message 4 of 37
Anonymous
in reply to: Anonymous

hi ,

I viewed this post recently , regarding  a code that you have writen (

We use multi body part modeling also for platework.
I have had to write some code and procedures to get: thickness, width and length parameters from the solid body part file to each individual part file.
The trick is to make components into sheet metal part files then flat pattern all files.
My code does all this.)
 
this sounds like the ticket that I need to half way become productive in inventor
     Is there anyway that you could send this code to me   please
 
                                                                              thanks
 
Message 5 of 37
barbara.han
in reply to: Anonymous

I personally like to use VBA. So what you want is to rename the solid1....solidX? The Inventor API allows you to change the Name of the solid - actually it's Name property of the SurfaceBody interface in Inventor API world.

 

Here is the code that you can try:

Sub changeSolidName()
    Dim ptDoc As PartDocument
    If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then
        MsgBox "please open a part document"
        Exit Sub
    End If
    Set ptDoc = ThisApplication.ActiveDocument
    Dim solid As SurfaceBody
    Dim j As Integer
    Dim prefix As String
    prefix = "Plate_"
    j = 1
    For Each solid In ptDoc.ComponentDefinition.SurfaceBodies
        solid.Name = prefix + IIf(j < 10, "0" + CStr(j), CStr(j))
        j = j + 1
    Next
End Sub

Hope this helps.

Barbara Han
Developer Technical Services
Autodesk Developer Network
Message 6 of 37
Anonymous
in reply to: barbara.han

Thank you for your help. The script work perfect. I modified a litle bit your script but source is the same.

Thank you one more time.

Message 7 of 37
PACDrafting
in reply to: Anonymous

Hi Saturator

 

Did you recieve my message sent to your inbox?

 

I actually put an ilogic code in there for you to rename the solid names.

 

Please reply to my inbox message and i'll send through to you the code to automatically transfer the thickness, width and length of solids to their repected individual parts generated.

 

Message 8 of 37
Anonymous
in reply to: Anonymous

Hello to all,

I need help in renaming solid body names. We use copy design at my work place often and renaming the solid bodies is a part of the task we have to keep all things in sync. The auto rename is a great iLogic rule for first time use but here we mane extend that naming to LH End Panel. Using the above logic rule I would lose the LH End Panel for example XXXXXX01 LH End Panel new body name YYYYYY01 I would like a rule that I can change the first characters that I specify like a find and replace all.

Any help would be greatly appreciated.

Message 9 of 37
adam.nagy
in reply to: Anonymous

Hi,

 

You could create a rule like this, where you can set what to replace with what:

myparam = InputBox(
	"/", 
	"Replace In Solid Name", 
	"ReplaceThis/WithThis (keep the '/' as separator)")

If (myparam <> "") Then
	myparams = myparam.Split("/")
	replaceString = myparams(0)
	withString = myparams(1)

	For Each solid In ThisDoc.Document.ComponentDefinition.SurfaceBodies
		name = solid.Name
		name = name.Replace(replaceString, withString)
		solid.Name = name
 	Next
End If

E.g. if I provided "My/Your" then it will replace all instances of "My" with "Your"

 

I hope this helps.

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 10 of 37
Curtis_Waguespack
in reply to: Anonymous

Hi tauwkh1,

 

adam.nagy's code looks like it might work well for you, but I used the code provided by Barbara Han to do something similar in the past as well:

http://inventortrenches.blogspot.com/2012/02/ilogic-to-rename-all-solid-bodies.html

 

I just thought I'd share that link in case it helps.

Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 11 of 37
Anonymous
in reply to: adam.nagy

Thank you for your help. This works perfectly and it was exactly what we wanted.

Message 12 of 37
kmiller
in reply to: PACDrafting

Hi there,

 

In your (PACDrafting's) comment above you talked about pushing values of length, height, and thickness into each individual part file.  Can I ask how you generally go about doing this?  Do you have a specific parameter for length, height, and thickness tied to each solid body? 

-------------------------------------------------------------------------------------------------

If this response answers your question please click "Accept as Solution".
Message 13 of 37
PACDrafting
in reply to: Anonymous

Hi

I export only the thickness parameter with the solid into sheet metal parts.
From there I am able to complete a flat pattern and get the length and width dimensions.
Message 14 of 37
kmiller
in reply to: PACDrafting

Sounds good.  Thank you.  I was just curious because it would be helpful for us to use something like this.  However the material we model potentially each "piece" could and may have a different L, H, Thk.  And these dimensions are not always on the same plane.  So I was just interested how other people where working with it.  I am not too familiar with sheet metal parts so I do not know if there is different functionality with that vs regular parts. 

 

Thanks for the insight though.

 

-------------------------------------------------------------------------------------------------

If this response answers your question please click "Accept as Solution".
Message 15 of 37
Anonymous
in reply to: barbara.han

solid.png

 

is this possible?

to rename the solid with a prefix"s" based on the selection made?

 

 

Message 16 of 37
Anonymous
in reply to: barbara.han

Yes that is possible with this routine

Wessley Hall
Senior Project Engineer
Tarrant Interiors
5000 South Freeway
Fort Worth, Texas 76115
Phone (817) 922-5000 ext. 1712
FAX (817)922-5015
Email wessley.hall@leggett.com

[cid:image002.jpg@01CE982A.6B5AE350]
Message 17 of 37
Anonymous
in reply to: Anonymous

I'm sorry I answered you incorrectly. The routine will ask you for what you want to replace with the new information. For example my solid is Steelxx and I want Alumyyy it works like find and replace

Message 18 of 37
Curtis_Waguespack
in reply to: Anonymous

Hi  akosi,

 

I don't have time to look at this at the moment, but this link has an example that looks at Sketch Block names, so it might help you move forward:

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/iLogic-code-to-turn-sketch-block-visib...

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 19 of 37
Anonymous
in reply to: Curtis_Waguespack

thanks for replying curtis...i was just checking out your inventortrenches blog..

 

im new in vba and am learning to code from this forum...

 

and i still have so much more to learn..Smiley Happy

Message 20 of 37
Anonymous
in reply to: adam.nagy

Could you tell me what I did wrong here?

I'm getting this error message:

 

Error in rule: Name, in document: Frame102-40Deriver.ipt

Conversion from string "22Deriver" to type 'Integer' is not valid.

 

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 5870 StartFragment: 314 EndFragment: 5838 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

myparam=InputBox("/", 
    "Replace In Solid Name", 
    "ReplaceFrame102-Deriver/WithFrame102-40Deriver (keep the '/' as separator)")If(myparam<>"")Thenmyparams=myparam.Split("/")replaceString=myparams("22Deriver")withString=myparams("40Deriver")ForEachsolidInThisDoc.Document.ComponentDefinition.SurfaceBodiesname=solid.Namename=name.Replace(replaceString, withString)solid.Name=nameNextEndIf

Tags (3)

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report