CoCreate User Forum  

Go Back   CoCreate User Forum > Applications > Annotation

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 02-26-2018, 10:32 AM
gmatelich's Avatar
gmatelich gmatelich is offline
Registered User
 
Join Date: Oct 2002
Location: Bellevue, WA, USA
Posts: 396
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 )
Reply With Quote
  #2  
Old 02-26-2018, 11:57 PM
Marten Marten is offline
Registered User
 
Join Date: Feb 2006
Location: Tilburg, The Netherlands
Posts: 139
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
Reply With Quote
  #3  
Old 03-08-2018, 02:37 PM
Wolfgang's Avatar
Wolfgang Wolfgang is offline
Registered User
 
Join Date: Nov 2002
Location: ... near Sindelfingen near Stuttgart, Germany
Posts: 754
Smile 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
gmatelich, you have been using a lisp form , which means it is a full defined lisp form with one or more pairs of round brackets ().

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.
Reply With Quote
  #4  
Old 03-08-2018, 03:21 PM
gmatelich's Avatar
gmatelich gmatelich is offline
Registered User
 
Join Date: Oct 2002
Location: Bellevue, WA, USA
Posts: 396
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")
I do still wish I had per sketch control of the Adjust point, so some could be center adjust and some be upper right adjust.
Reply With Quote
  #5  
Old 03-09-2018, 05:21 AM
tom kirkman's Avatar
tom kirkman tom kirkman is offline
Registered User
 
Join Date: Oct 2002
Location: Perrysburg, Ohio
Posts: 397
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")
The adjust number is the same as your number pad

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.
Attached Files
File Type: lsp change-card.lsp (5.0 KB, 560 views)
__________________
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
Reply With Quote
  #6  
Old 03-10-2018, 06:54 AM
Wolfgang's Avatar
Wolfgang Wolfgang is offline
Registered User
 
Join Date: Nov 2002
Location: ... near Sindelfingen near Stuttgart, Germany
Posts: 754
Re: Load sketch, choose position

Quote:
Originally Posted by tom kirkman View Post
You can add an adjustment (insert) point to your insert sketch command.
perfect! :-)
---------------
Quote:
Originally Posted by tom kirkman View Post
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.
a few LISP related remarks:
  • you don't need (OI_TOOLS:: prefix, because it is within your OWN package : (in-package :OI_TOOLS)
  • you don't need (oli:: prefix in your code, because there is (use-package :OLI)
  • I dont see the need for the global variable Eff
  • I recommend to change your ok-action and the defun to:
    Code:
    ...
    :ok-action'(sd-call-cmds (change-cards Effectivity))
    ) ;; end dialog
    
    ;defines the changed card function
    (defun change-cards (eff)
    ....
    )
    +removing the global variable Eff. This means you pass over the value of the dialog variable as parameter to the function
  • handling the corners of the sheet with string-number-string conversion looks cumbersome to me, and the conversion is not needed at all
  • within the defun you are creating a bunch of more new global variables (by accident), without the need to do so.
    Question: have you ever used a (LET (..) ...) statement?
  • you can remove your condition and generate the file name directly from the parameter:
    Code:
    (AM_LOAD_SKETCH 
    	:FILENAME (format nil "~A/ANNOTATION/Sketches/Change Card/Change-~A.mi" OICUSTDIR Eff)
    	:adjust 7
    	:PICK_PNT pick-point)
    if you are adding other cases I would ONLY generate the new (base)filename within the condition and have just one lisp call of loading sketch with the new filename.
Those are just friendly hints to perform the quality of the lisp code. I have no doubt about the functionality as it is!
Reply With Quote
  #7  
Old 03-12-2018, 04:05 AM
tom kirkman's Avatar
tom kirkman tom kirkman is offline
Registered User
 
Join Date: Oct 2002
Location: Perrysburg, Ohio
Posts: 397
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.
Reply With Quote
  #8  
Old 03-13-2018, 04:26 AM
Marten Marten is offline
Registered User
 
Join Date: Feb 2006
Location: Tilburg, The Netherlands
Posts: 139
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
Reply With Quote
  #9  
Old 03-13-2018, 05:24 AM
tom kirkman's Avatar
tom kirkman tom kirkman is offline
Registered User
 
Join Date: Oct 2002
Location: Perrysburg, Ohio
Posts: 397
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
Reply With Quote
  #10  
Old 03-14-2018, 05:05 AM
Wolfgang's Avatar
Wolfgang Wolfgang is offline
Registered User
 
Join Date: Nov 2002
Location: ... near Sindelfingen near Stuttgart, Germany
Posts: 754
Re: Load sketch, choose position

Quote:
Originally Posted by Marten View Post
If I add it to "sd-am-define-annotation-template" I get the error: Keyword :ADJUST is not allowed
Code:
(oli:sd-am-define-annotation-template
  :type    :SKETCH
....
  :2d-file the-filename
  :action  "am_load_sketch_multiple :adjust 8")
Make the :adjust 8 part of the action string.

Hope that works now.
Reply With Quote
  #11  
Old 03-14-2018, 05:15 AM
Wolfgang's Avatar
Wolfgang Wolfgang is offline
Registered User
 
Join Date: Nov 2002
Location: ... near Sindelfingen near Stuttgart, Germany
Posts: 754
Re: Load sketch, choose position

Quote:
Originally Posted by tom kirkman View Post
I am not familiar with the proper use of the (LET(..)...) statement.
I recently explained it in the german forum (next is an online translation):

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.
Reply With Quote
  #12  
Old 03-15-2018, 12:54 AM
Marten Marten is offline
Registered User
 
Join Date: Feb 2006
Location: Tilburg, The Netherlands
Posts: 139
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
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 03:14 AM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.