Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hi All,
I might have a strange request but if I could somehow make it work it would save me a lot of time.
For a customer I'm having family tables usually consisting of approx. 70 members which all have their own drawings with their specific information. This information is controlled by the family table so usually there's no work to be done on the drawing except from creating them. Normally I do this by simply copy 1 drawing multiple times open them and replace the family table instance with the right instance. For this I always use the exact same number for drawing and instance.
Now it would be great if I can have a mapkey which will replace the drawing model by an instance with the same number as the drawing. If I can make this work I can run this mapkey in Creo distributed batch and the whole cycle is automated.
Any help would be very much appreciated!
Bart
Hi,
I am note sure if the following info will help you ...
In the past I created AutoIt script Open_Model_Drawing_AutoIt. It is able to get the name of current model from window title and open drawing of current model. Maybe this procedure enables you to get the name of current drawing and replace drawing model instance having the same name.
https://community.ptc.com/t5/Part-Modeling/Creo-2-0-Open-a-drawing-from-active-part/m-p/260926
Hi Martin,
I've looked in these files but I'm not able to see what it's exactly doing. Probably because I'm not a skilled programmer 😉
However I also have a mapkey used for opening or creating a drawing for the active model but this seems to copy the name out of the model tree but in this case that's the wrong name since I want it to use the drawing name.
Best regards,
bart
Hi,
in case that you do not understand the contents of open_drawing_cr2.au3 source file then I cannot help you 😞
Maybe you can use translate.google.com to translate comments from Czech to English.
You can use the same basic principles outlined in this Mapkey Writing/Edit Tips post but you may have to customize them for your needs. Basically, you can mix and customize these mapkeys to take the active Creo object and put the name into commands all over Creo (most common being open, new, and save).
Here's an example that worked for me in Creo 4 M090. I made a version 2 of >partnameopen that removed the .DRW file extension to make it more flexible to be able to open a DRW (db_4), ASM (db_1), PRT (db_2), etc which have been bolded below. You will need to copy the >storetmpfile and >loadconf mapkeys from the other web page. Notes: this RDM mapkey first tries to open a part with the same name as the active drawing and then an assembly if that doesn't work.
mapkey rdm @MAPKEY_NAMEReplace drawing model with name of the active drawing;\
mapkey(continued) @MAPKEY_LABELReplace Drawing Model (rdm);\
mapkey(continued) %>storetmpfile;%>partnameopen2;%>loadconf;\
mapkey(continued) ~ Command `ProCmdDwgReplaceViewModel`;\
mapkey(continued) ~ Activate `gen_repl_dlg` `PB_NewComp`;\
mapkey(continued) ~ Select `file_open` `Type` 1 `db_2`;\
mapkey(continued) %partnameopen2;\
mapkey(continued) ~ Activate `file_open` `Inputname`;\
mapkey(continued) ~ Select `file_open` `Type` 1 `db_1`;\
mapkey(continued) %partnameopen2;\
mapkey(continued) ~ Activate `file_open` `Inputname`;\
mapkey(continued) ~ Select `main_dlg_cur` `DrwAssyTree` 1 `node0:view_2 92 0 2 -1 -1`;\
mapkey(continued) ~ Activate `gen_repl_dlg` `CB_DwgDelOrig` 1;\
mapkey(continued) ~ Activate `gen_repl_dlg` `CB_DwgReplItems` 1;\
mapkey(continued) ~ Activate `gen_repl_dlg` `DoneBtn`;
mapkey >partnameopen2 @MAPKEY_LABELActive model name for open cmd;\
mapkey(continued) @SYSTEMdel sw.pro\n\
mapkey(continued) dir /b *.pic>\%temp\%\\filename.txt\n\
mapkey(continued) set /p VAR1=<\%temp\%\\filename.txt\n\
mapkey(continued) del \%temp\%\\filename.txt\n\
mapkey(continued) set FILENAME=\%VAR1:\~0,-4\%\n\
mapkey(continued) echo mapkey partnameopen2 \~ Update `file_open` \
mapkey(continued) `Inputname` `\%FILENAME\%`\;>>sw.pro\n\
mapkey(continued) del *.pic;