cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Make macro for Isodraw CadProcess 7.2 to rename object id & name

RubenCote
3-Visitor

Make macro for Isodraw CadProcess 7.2 to rename object id & name

How do I create a macro for IsoDraw CadProcess 7.2 to be able to edit the object id of the assembly group and then copy that over to the object name so that both the object id and object name are the same? Also I need to truncate the object id and name to only show the characters to the right of the hyphen.

1 ACCEPTED SOLUTION

Accepted Solutions

Trevor,

You're the man. Thanks for the final help. It finally worked like a charm. Great!!! Thank you very much.

Here's the final code that worked.

Macro rename_assembly_name

Define el as Element

Define where as Integer

Define Output as String

Define bad as integer

Define good as integer

Define total as integer

select if Object_info exists

subselect if OBJECT_ID Contains "-"

el=ActiveDoc.FirstSelectedElement

WHILE (Exists (el) = true)

total=Len(el.info.id)

where=Find(el.info.id,"-",1)

good=(total - where)

If (where <> 0)

Output=Right(el.info.id,good)

el.info.id=Output

el.info.name=Output

end if

el = el.nextSelectedElement

End While

message "Assemblies have been renamed."

select none

End Macro

View solution in original post

9 REPLIES 9

How do you intend to retain a unique ids if you use the content to the right of the hyphen?

I see multiples of many of the objects.

What happens is there is no hyphen or if there is no content after the hyphen or if there are multiple hyphens?

By default the object_id has an underscore and a different number (example,screw _1, screw _2, screw_3, screw_4) to the right of the hyphen. So the system has created a unique object_id. I just want to strip the engineering number out of the object_id and then copy that to the name_id. Having the object_id and object_name can be the same, I think. Isodraw does not mind that. I'm thinking a while statement would check to see if the condition exists. So those that don't match would have to be fixed manually, but at least the bulk of the list would fall under and be fixed by the macro. Right now I'm doing the renaming of object_id and object_name by hand and it takes too long. Hence the need for the macro. My end goal is to export the file once the renaming of the object_id and object_name has been done to a .u3d file that will be placed in an acrobat pdf file.

Okay I was able to make a macro that truncates the Object_id and copies the output over to the Object_name. The only problem that I'm having is that it is not looping. If I select and run the macro from the list it changes the next item on the list. Need to have it loop. I added a while statement but not sure what I did wrong to not make it loop down the selected list. Any help is much appreciated.

Macro to Truncate Object ID and Copy it Over to Object Name

Define Object_type as string

Define Object_info as string

Define el as element

Define where as Integer

Define Output as String

Define bad as integer

Define good as integer

Define total as integer

SELECT IF OBJECT_ID Contains "-"

WHILE (Exists (el) = true)

total=Len(ActiveDoc.FirstSelectedElement.info.id)

where=Find(ActiveDoc.FirstSelectedElement.info.id,"-",1)

good=(total - where)

Output=Right(activeDoc.firstSelectedElement.info.id,good)

activeDoc.firstSelectedElement.info.id=Output

activeDoc.firstSelectedElement.info.name=Output

Wait timer 30 else

message "No more assemblies to rename."

break

el = el.nextSelectedElement

End While

Select None

End Macro

First, I haven't tested this. Just went through some old code. Looks like you're not making a group to select from. Below is an update to the code in which I added 'el = ActiveDoc.FirstSelectedElement'. You should now be able to select multiple elements any way your prefer and then run the macro. If it just needs to run on the entire page just add before the command your selection criteria.

Macro to Truncate Object ID and Copy it Over to Object Name

Define Object_type as string

Define Object_info as string

Define el as element

Define where as Integer

Define Output as String

Define bad as integer

Define good as integer

Define total as integer

el = ActiveDoc.FirstSelectedElement

SELECT IF OBJECT_ID Contains "-"

WHILE (Exists (el) = true)

total=Len(ActiveDoc.FirstSelectedElement.info.id)

where=Find(ActiveDoc.FirstSelectedElement.info.id,"-",1)

good=(total - where)

Output=Right(activeDoc.firstSelectedElement.info.id,good)

activeDoc.firstSelectedElement.info.id=Output

activeDoc.firstSelectedElement.info.name=Output

Wait timer 30 else

message "No more assemblies to rename."

break

el = el.nextSelectedElement

End While

Select None

End Macro

Hi Trevor,

I copied your code and tried it and get sporatic results. One thing for sure the macro does not run through the selected list. It tends to try to change the first selected group on the list. If I continue to select and run the macro again, manually, then it continues down the list until the last renaming is done. Weird at best. This was the problem I was getting when I first posted the code. The macro will run, if I cycle it by selecting from the list and running it. It won't go through the list automatically. Looking at what i posted I realize now that I forgot to cut and paste the line you added, which was there in the code I pasted from. The macro code looks right but I don't know why it does not run automatically through the selected list. Attached is the .wrl file I'm testing the code with and using to open in IsoDraw Cadprocess 7.2.

Macro rename_assembly_name

Define Object_type as string

Define Object_info as string

Define el as element

Define where as Integer

Define Output as String

Define bad as integer

Define good as integer

Define total as integer

Define j as string

el=ActiveDoc.FirstSelectedElement

SELECT IF OBJECT_ID Contains "-"

WHILE (Exists (el) = true)

total=Len(ActiveDoc.FirstSelectedElement.info.id)

where=Find(ActiveDoc.FirstSelectedElement.info.id,"-",1)

good=(total - where) Output=Right(activeDoc.firstSelectedElement.info.id,good)

activeDoc.firstSelectedElement.info.id=Output

activeDoc.firstSelectedElement.info.name=Output

Wait timer 15 else

message "No more assemblies to rename."

break

el = el.nextSelectedElement

End While

Select none

End Macro

Move your select up a line. Might need to change it to a subselect.

Why 'break'? Take it out.

okay I tried making it into a subselect but I still find that the macro needs to be reselected manually each time so that it can do the next on the list. The following does change the object_id to what is desired but I can't get it to select and run for the next assembly automatically.

Macro rename_assembly_name

Define el as Element

Define where as Integer

Define Output as String

Define bad as integer

Define good as integer

Define total as integer

select if Object_info exists

subselect if OBJECT_ID Contains "-"

el=ActiveDoc.FirstSelectedElement

WHILE (Exists (el) = true)

total=Len(ActiveDoc.FirstSelectedElement.info.id)

where=Find(ActiveDoc.FirstSelectedElement.info.id,"-",1)

good=(total - where)

If (where <> 0)

Output=Right(activeDoc.firstSelectedElement.info.id,good)

activeDoc.firstSelectedElement.info.id=Output

activeDoc.firstSelectedElement.info.name=Output

message Output

end if

el = el.nextSelectedElement else

message "No more assemblies to rename."

End While

subselect none

select none

End Macro

Here's another untested version. If this doesn't work please try debugging the macro using the built in IsoDraw debug tool. It allows you to step through the macro and see where it's dropping out.

If that doesn't work, please provide a dumbed down example file that demonstrates the issue.

Here's the macro with some tweaks. I'm not sure that the else you had at the end works like that. If it does, I'm surprized.

Macro rename_assembly_name

Define el as Element

Define where as Integer

Define Output as String

Define bad as integer

Define good as integer

Define total as integer

select if Object_info exists

subselect if OBJECT_ID Contains "-"

el=ActiveDoc.FirstSelectedElement

WHILE (Exists (el) = true)

total=Len(el.info.id)

where=Find(el.info.id,"-",1)

good=(total - where)

If (where <> 0)

Output=Right(el.id,good)

activeDoc.firstSelectedElement.info.id=Output

activeDoc.el.info.name=Output

message Output

end if

el = el.nextSelectedElement

End While

message "No more assemblies to rename."

select none

End Macro

Trevor,

You're the man. Thanks for the final help. It finally worked like a charm. Great!!! Thank you very much.

Here's the final code that worked.

Macro rename_assembly_name

Define el as Element

Define where as Integer

Define Output as String

Define bad as integer

Define good as integer

Define total as integer

select if Object_info exists

subselect if OBJECT_ID Contains "-"

el=ActiveDoc.FirstSelectedElement

WHILE (Exists (el) = true)

total=Len(el.info.id)

where=Find(el.info.id,"-",1)

good=(total - where)

If (where <> 0)

Output=Right(el.info.id,good)

el.info.id=Output

el.info.name=Output

end if

el = el.nextSelectedElement

End While

message "Assemblies have been renamed."

select none

End Macro

Top Tags