#1
|
||||
|
||||
Load sketch, choose position
I’m trying to create a button in the UI to load an .mi file as a sketch, in the current sheet, and choose a position. I figure I’ll put it in am_avail_cmds.cmd. Starting with recorder, and poking around the help I think the command should look something like
(AM_LOAD_SKETCH :FILENAME (format nil "~A/VersionNeutral/Annotation/NotesCastMetal.mi" (oli::sd-sys-getenv "SDSITECUSTOMIZEDIR")) :position (gpntdocu :point-2d)) But I can’t figure out the position portion. I can just do 0,0 and move after load, but that’s pretty lame. I’d like it to behave the same as using the UI, where the sketch is now hanging on my cursor waiting to be placed. I’m not sure how to tell it “load the file and wait for the user to pick a point on the drawing” I can use AM_LOAD_SKETCH from the command line, but it doesn’t work when I put it in am_avail_cmds.cmd I’m also trying this from the help, but it doesn’t work either. (sd-am-load-sketch :file_name "test.mi" :position 0,0 :adjust :upper_left :current-sheet :adjust ) |
#2
|
|||
|
|||
Re: Load sketch, choose position
It depends on the context what works, but here are two options:
Put it in avail_cmds like this: (oli::sd-put-buffer "AM_LOAD_SKETCH :FILENAME (format nil \"~A/VersionNeutral/Annotation/NotesCastMetal.mi\" (oli::sd-sys-getenv \"SDSITECUSTOMIZEDIR\"))") Or, don't pass : position, but add :interactive-rest to the command But, I think you want to load some standard text-blocks etc. Then your best option is to use templates. They are located in the template-browser, and you can very easily add your own (using "Define" in tab "insert", group "Sketch") With kind regards, Marten |
#3
|
||||
|
||||
Re: Load sketch, choose position
Marten already gave a good answer.
If we look to the IKIT documentation for the SD-DEFINE-AVAILABLE-COMMAND we will find the following for the action: Code:
:action {STRING or LISP-form} - the command action A string can be anything. In the case of available command, the content of the :action will be put-buffered into the 'command line' (to say in with a kind of picture). Therefore the usage of oli:sd-put-puffer is not needed. What is needed in your case Gmaetlich is that the dialog you are calling is getting interactive. a) you can call a dialog capsualted within round brackets (CREATE_PART ... ) .. then everything has to be defined, so that he ok-action of the dialog can be performed. (this one we call also a 'fully qualified' call) b) you can call a dialog without the round brackets. then it will react as when typing one thing ofter the other into the command line. for b) if we ommit parts of the command to make it complete, the 'put-buffered' dialog will get interactive and its UI (if any) will pop up instead of (AM_LOAD_SKETCH :FILENAME ......) use AM_LOAD_SKETCH :FILENAME .... and it will get interactive (sketch attached to cursor and asking for a position) since the action is a string in the latter case we need to escape the double quotes (as Marten did as well) The following would be sufficient: Code:
:action "AM_LOAD_SKETCH :FILENAME (format nil \"~A/VersionNeutral/Annotation/NotesCastMetal.mi\" (oli::sd-sys-getenv \"SDSITECUSTOMIZEDIR\"))" Last but not least: the template browser is a very good thing. You can also figure out the tiny LSP file for one template , modify it, or copy and modify it to make use of envirnment variables.
__________________
|
#4
|
||||
|
||||
Re: Load sketch, choose position
Thank you both for the great advice. I did end up using the Template functionality. Originally I had set it up as a symbol and was frustrated by how locked down a symbol was, hence my desire to load my own sketch. Eventually I figured out I could also define sketch templates instead of symbol templates. I added these to my am_customize in my SDSITECUSTOMIZEDIR
Code:
(oli:sd-am-define-annotation-template :type :SKETCH :name "Notes - Plastic" :path "/Notes" :image (format nil "~A/VersionNeutral/Annotation/NotesPlastic.bmp" (oli::sd-sys-getenv "SDSITECUSTOMIZEDIR")) :2d-file (format nil "~A/VersionNeutral/Annotation/NotesPlastic.mi" (oli::sd-sys-getenv "SDSITECUSTOMIZEDIR")) :action "am_load_sketch_multiple") |
#5
|
||||
|
||||
Re: Load sketch, choose position
You can add an adjustment (insert) point to your insert sketch command.
Code:
(oli:sd-am-define-annotation-template :type :SKETCH :adjust 8 :name "Notes - Plastic" :path "/Notes" :image (format nil "~A/VersionNeutral/Annotation/NotesPlastic.bmp" (oli::sd-sys-getenv "SDSITECUSTOMIZEDIR")) :2d-file (format nil "~A/VersionNeutral/Annotation/NotesPlastic.mi" (oli::sd-sys-getenv "SDSITECUSTOMIZEDIR")) :action "am_load_sketch_multiple") 7 8 9 4 5 6 1 2 3 7 is the upper left 3 is the lower right. I am adding an example lisp. This adds change cards to a drawing. The type of change card is dependent upon the type of change. The change card always goes below the lower left hand corner of the drawing. So this program finds the drawing corners and properly places the change card.
__________________
Tom Kirkman Creo Elements/Direct 20.1 Dell Precision 3581 https://www.o-i.com Last edited by tom kirkman; 03-09-2018 at 05:23 AM. Reason: add lisp file |
#6
|
||||
|
||||
Re: Load sketch, choose position
Quote:
--------------- Quote:
__________________
|
#7
|
||||
|
||||
Re: Load sketch, choose position
Thank you Wolfgang.
I will make these changes and give it a try. I am not familiar with the proper use of the (LET(..)...) statement. Regards Tom
__________________
Tom Kirkman Creo Elements/Direct 20.1 Dell Precision 3581 https://www.o-i.com Last edited by tom kirkman; 03-12-2018 at 04:13 AM. |
#8
|
|||
|
|||
Re: Load sketch, choose position
Hi Tom,
Have you tried the :adjust keyword? If I add it to "sd-am-define-annotation-template" I get the error: Keyword :ADJUST is not allowed I also tried to add it to :action, but that also doesn't work. As far as I can see :adjust is part of "am_load_sketch_multiple" and not of "sd-am-define-annotation-template" I use Version 19 Regards, Marten |
#9
|
||||
|
||||
Re: Load sketch, choose position
Marten
You are right, but let me try a few things and see if anything else works. Tom
__________________
Tom Kirkman Creo Elements/Direct 20.1 Dell Precision 3581 https://www.o-i.com |
#10
|
||||
|
||||
Re: Load sketch, choose position
Quote:
Code:
(oli:sd-am-define-annotation-template :type :SKETCH .... :2d-file the-filename :action "am_load_sketch_multiple :adjust 8") Hope that works now.
__________________
|
#11
|
||||
|
||||
Re: Load sketch, choose position
Quote:
https://translate.google.com/transla...-text=&act=url Original Link is http://ww3.cad.de/foren/ubb/Forum29/HTML/004652.shtml#000007 Post created at Feb 21, 2018 18:32. If the online translation doesn't work well for you, just drop me a note here again.
__________________
|
#12
|
|||
|
|||
Re: Load sketch, choose position
Hi Wolfgang,
I had tried adding :adjust to the :action, but that doesn't work either. It seems that the string passed to :action is not the command which is executed, but is a string to specify the template browser which command to use. If I add :adjust to :action I don't get the sketch command, but the insert symbol command. So it seems the string from the action-keyword is used in a case-statement where the proper command is build up. If that is the case the only option for :adjust to work is if it is implemented for sd-am-define-annotation-template. As CED is currently in maintenance mode I don't keep my hopes up for this to be implemented (only if a big customer of PTC requests it, which we are not). With kind regards, Marten Verhoeven |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | Rate This Thread |
|
|