Skip to main content
1-Visitor
November 14, 2014
Solved

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

  • November 14, 2014
  • 1 reply
  • 4597 views

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.

Best answer by RubenCote

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

1 reply

12-Amethyst
November 20, 2014

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?

RubenCote1-VisitorAuthor
1-Visitor
November 20, 2014

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.

RubenCote1-VisitorAuthor
1-Visitor
December 5, 2014

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