Open umesh-timalsina opened 2 years ago
HI Umesh, Typically when I have functionality that is not in the core CREOSON directly I write a mapkey. I'm actually planning a tool that will help us run a test on models before sending them to production. Interference is one of the top tests we do.
Here is a very basic mapkey functionality that you can use.
mapkey(continued) ~ Command `ProCmdNaModelGlobalInterfe` ;\
mapkey(continued) ~ Activate `nma_model_global_interference` `compute_btn`;
Hope this helps
@DieSwartKat Thanks, that's actually very useful. I was planning to write my own little jlink interface just to perform the Interference analysis, but resolving it by mapkeys is a good idea. For the former, I found an example at:
C:\Program Files\PTC\Creo x.x.x.x\Common Files\otk_java_free\otk_java_appls\jlinkexamples\UsrInterference.java
One quick question though, will recording a mapkey for interference analysis and calling it from CREOSON also provide the information that we can get from the check in CREO?
Yeah, the jlink interface will probably be a little more elegant. But what I normally do is save the results as a text file and then pick it with from there. I've added it into the mapkey so you can see.
mapkey(continued) ~ Command `ProCmdNaModelGlobalInterfe` ;\
mapkey(continued) ~ Activate `nma_model_global_interference` `compute_btn`;\
mapkey(continued) ~ Activate `nma_model_global_interference` `info_btn`;\
mapkey(continued) ~ Select `texttool` `MenuBar` 1 `FileMenu`;\
mapkey(continued) ~ Close `texttool` `MenuBar`;\
mapkey(continued) ~ Activate `texttool` `SaveAsPushButton`;\
mapkey(continued) ~ Update `file_saveas` `Inputname` `c:\\\\glbintf.dat`;\
mapkey(continued) ~ Activate `file_saveas` `OK`;\
mapkey(continued) ~ FocusIn `texttool` `textPH.TextArea`;\
mapkey(continued) ~ Activate `texttool` `CloseButton`;\
mapkey(continued) ~ Activate `nma_model_global_interference` `cancel_btn`;
I decided to use python with a django website running locally. It's a little hacky, but the fact that I can use python is a big plus for me.
Yeah, the jlink interface will probably be a little more elegant. But what I normally do is save the results as a text file and then pick it with from there. I've added it into the mapkey so you can see.
Thanks a ton. The package we have is entirely written in python as well. Calling another java process is surely a pain from here.
Well, this might be a RTFM scenario but can you point me to the documentation for the CLI commands used for mapkeys? I would like to get some understading of the commands used here and write a custom mapkey script that will do the task for us.
I'm using CREO 3.0 M190 so I hope it's the same in your interface. I type 'mapkey' in the search bar in top right hand corner to find it.
I've linked it to a mapkey when I type mk :
mapkey mk @MAPKEY_LABELMap Key;@MAPKEY_LABELMap Key;\
mapkey(continued) ~ Select `main_dlg_cur` `appl_casc`;\
mapkey(continued) ~ Select `main_dlg_cur` `appl_menu.left_pane.manage_file_casc`;\
mapkey(continued) ~ Close `main_dlg_cur` `appl_casc`;\
mapkey(continued) ~ Command `ProCmdRibbonOptionsDlg` ;\
mapkey(continued) ~ Select `ribbon_options_dialog` `PageSwitcherPageList` 1 `env_layouts`;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `env_layouts.Env_MapkeySet_Btn`;
This allow you to record mapkeys. You can also check all the names for existng mapkeys not to overwrite. We have a standard starting directory. CREO place in memory the mapkeys from three different locations... but I can only remember too, if you look at the documentation it will explain more. location one is the admin mapkeys: C:\PTC\Creo 3.0\M190\Common Files\text\config.pro
location two for the private mapkeys is the start directory. This is set by the batch file we use when we start CREO. For us it is C:\PTC\Bar_Start_Creo You can set it with the a shortcut and use the start in field.
I'm over explaining because I don't know what information you have already.
I sometimes make a recording of a mapkey and then save it in a .pro file at a default location of my choosing. I can then edit it manually with a text editor till I get the results I want. If you do this you need to import the mapkey into CREO's memory. The long way to do this is to place it in the start directory and then restart CREO (not recommended)
Rather go to File > Options > Configuration Editor > Options (import / export) Select your .pro file. Click ok on the PTC CREO parametric option and then say no for the dialog box that pop up.
You can test the mapkey by running it with your keyboard command. You can also save the above steps in a mapkey, as long as you always use the same .pro path/filename.
Hope this helps.
I should probably mention there is no documentation for mapkey "language". The best way to use it by recording it and then read what you have recorded. There is nothing fancy about it. It a set of instructions and you cannot apply any logic to it. Highly dump, and it's debatable if it could even be called a language.
You will also find that there is not logic in the mapkey that if a scenario occur that is not planned for it just causes havoc! So you might want to carefully choose were a mapkey starts and ends and they you use your python code to confirm that you got what you expected.
I also sometime construct the mapkey with the python code. It gives it another dimension that really allows you to add to the mix of possibilities.
Checkout my youtube videos for stuff I've done with it. https://youtube.com/playlist?list=PLgSKTQeiqHa122sc8u3rBnpmxppFMdOuI
Also the mapkey feature in CREOSON just send the command, but you have no visibility if it actually ended. This is super frustration because when you expect a file result from CREO then the next step for you python script is normally to read that file. CREO might still be doing it's thing while the python code is done with the sinding. This obviously will cause your python code to fail.
So I've added to the end of my mapkey function a few extra steps which I get CREO to complete. I let CREO create a text file. I call my ready.txt. I then tell my python code to wait for that file. When it finds it it delete the ready.txt file and know that CREO is ready for the next command. Again very hacky, but it gets the job done. I don't have much experience with jlink, but I would expect it to be a little more elegant to work with, although my stomach turns every time I think that I need to get to learn java just for this. So I leave it with the hack in python instead. For the most part I've been able to isolate a few bugs and created work around for them.
Hope this help.
I'm using CREO 3.0 M190 so I hope it's the same in your interface. I type 'mapkey' in the search bar in top right hand corner to find it.
I've linked it to a mapkey when I type mk :
mapkey mk @MAPKEY_LABELMap Key;@MAPKEY_LABELMap Key;\ mapkey(continued) ~ Select `main_dlg_cur` `appl_casc`;\ mapkey(continued) ~ Select `main_dlg_cur` `appl_menu.left_pane.manage_file_casc`;\ mapkey(continued) ~ Close `main_dlg_cur` `appl_casc`;\ mapkey(continued) ~ Command `ProCmdRibbonOptionsDlg` ;\ mapkey(continued) ~ Select `ribbon_options_dialog` `PageSwitcherPageList` 1 `env_layouts`;\ mapkey(continued) ~ Activate `ribbon_options_dialog` `env_layouts.Env_MapkeySet_Btn`;
I am using CREO 5, but the interface to find and record mapkeys is the same. Thanks.
This allow you to record mapkeys. You can also check all the names for existng mapkeys not to overwrite. We have a standard starting directory. CREO place in memory the mapkeys from three different locations... but I can only remember too, if you look at the documentation it will explain more. location one is the admin mapkeys: C:\PTC\Creo 3.0\M190\Common Files\text\config.pro location two for the private mapkeys is the start directory. This is set by the batch file we use when we start CREO. For us it is C:\PTC\Bar_Start_Creo You can set it with the a shortcut and use the start in field.
I'm over explaining because I don't know what information you have already.
I sometimes make a recording of a mapkey and then save it in a .pro file at a default location of my choosing. I can then edit it manually with a text editor till I get the results I want. If you do this you need to import the mapkey into CREO's memory. The long way to do this is to place it in the start directory and then restart CREO (not recommended)
Rather go to File > Options > Configuration Editor > Options (import / export) Select your .pro file. Click ok on the PTC CREO parametric option and then say no for the dialog box that pop up.
You can test the mapkey by running it with your keyboard command. You can also save the above steps in a mapkey, as long as you always use the same .pro path/filename.
Hope this helps.
My understanding is that having a mapkey command can eliminate the need for config.pro
file and use CREOSON directly to send mapkeys. Here's what I did (and it worked with CREO 5). Recorded and Saved a mapkey to config.pro
. Finally, Modified its contents to do what I like and restarted creo by removing the map key. Subsequent calls to the mapkey happens from CREOSON which then runs the commands in series. Which inevitably led to the following issue:
You will also find that there is not logic in the mapkey that if a scenario occur that is not planned for it just causes havoc! So you might want to carefully choose were a mapkey starts and ends and they you use your python code to confirm that you got what you expected.
Your solution here works well. But it might be nice to get some first class support for it in CREOSON itself.
So I've added to the end of my mapkey function a few extra steps which I get CREO to complete. I let CREO create a text file. I call my ready.txt. I then tell my python code to wait for that file. When it finds it it delete the ready.txt file and know that CREO is ready for the next command.
Again very hacky, but it gets the job done. I don't have much experience with jlink, but I would expect it to be a little more elegant to work with, although my stomach turns every time I think that I need to get to learn java just for this. So I leave it with the hack in python instead. For the most part I've been able to isolate a few bugs and created work around for them.
Yeah. JLink and learning java would involve quite the tooling effort but in the end might be worth it. The examples provided by PTC are a good starting point IMO. If we could package up some basic interference analysis as a CLI tool dumps a json report of some kind. It would be relatively stable.
I've had a lot of success with mapkeys. But it takes a bit of playing around with CREO to eliminate issues as much as possible. In my experience it is typically a problem when the user don't have CREO exactly at the correct place to start the mapkey. So I have a layer of logic or validation to determine this, or I make sure I control as much of the process as possible. I've pretty much standardized the start point as having the first layer assembly (or main assembly) open. We built all our procedures around it and currently have very little issues.
@DieSwartKat Thanks For your suggestion. While your approach works good, Our requirement needed something more generic. For anybody intersted, I have spunup a basic server (Following logic from the creoson
source code) to write a basic InterferenceHandler
here. Its pretty basic and only computes the global interferences now. Wrote java after ages, pardon the silly anti-patterns if you notice any.
@umesh-timalsina This is really neat! I'll give it a spin in the morning and give you my feedback.
We have been using CREOSON in one of our projects to do some mass properties as well as other analysis on our CAD models. I was wondering if we could do basic interference analysis with CREOSON. Based on the functions I browsed, It seems like its unsupported currently. Are there any plans to integrate interference analysis with CREOSON?