Writing dialogs for the Annotation module is almost as easy as
writing dialogs for the core product.
There are just a few things to take care of.
Annotator objects can be selected using the keywords
The result returned after having picked into the viewport can be used to inquire
Task: "Write a dialog to delete lines and circles created by the user"
Solution 1: using sd-get-annotator-position:
;; this is Creo Elements/Direct Modeling LISP code (in-package :oli) (sd-defdialog 'sd-delete-user-line-circle :dialog-control :sequential-loop :variables '( (delete-start :selection (*sd-anno-line-seltype* *sd-anno-circle-seltype*) :select-attribute :docu-user-geo-only :prompt-text ("Pick lines/circles to be deleted" 1) :after-input (sd-execute-annotator-command :cmd (format nil "DELETE SELECT GLOBAL ~A CONFIRM END" (sd-get-annotator-position :object delete-start) )) ) ) )
Solution 2: using sd-get-annotator-reference
;; this is Creo Elements/Direct Modeling LISP code (in-package :oli) (sd-defdialog 'sd-delete-user-line-circle :dialog-control :sequential-loop :variables '( (delete-start :selection (*sd-anno-line-seltype* *sd-anno-circle-seltype*) :select-attribute :docu-user-geo-only :prompt-text ("Pick lines/circles to be deleted" 1) :after-input (sd-execute-annotator-command :cmd (format nil "DELETE SELECT GLOBAL POINTER ~A CONFIRM END" (sd-get-annotator-reference :object delete-start) )) ) ) )
Sometimes it is required not to select an existing Annotator object but
to simply get a certain position in 2D space by picking into empty space.
Creating a polygon of lines is a typical task requiring this
functionality.
To get a point simply set the value type
:docupntcnp
The LISP object returned is of type GPNTDOCU.
(gpntdocu_x gpntdocu) (gpntdocu_y gpntdocu)
Task: "Write a dialog to create rectangles"
;; this is Creo Elements/Direct Modeling LISP code (in-package :oli) (sd-defdialog 'sd-am_geo_rectangle :dialog-control :sequential-loop :variables '( (rectangle-start :value-type :docupntcnp :prompt-text ("Indicate corner of rectangle" 1) :after-input (sd-execute-annotator-command :cmd (format nil "LINE ASSIST RECTANGLE ~A,~A" (gpntdocu_x rectangle-start) (gpntdocu_y rectangle-start))) ) (rectangle-end :value-type :docupntcnp :prompt-text ("Indicate opposite corner of rectangle" 2) :after-input (sd-execute-annotator-command :cmd (format nil "~A,~A" (gpntdocu_x rectangle-end) (gpntdocu_y rectangle-end))) :next-variable rectangle-start ) ) :ok-action '(sd-execute-annotator-command :cmd "end") :cancel-action '(sd-execute-annotator-command :cmd "end") )
© 2024 Parametric
Technology GmbH (a subsidiary of PTC Inc.), All Rights Reserved |