CoCreate User Forum

CoCreate User Forum (https://www.cocreateusers.org/forum/index.php)
-   Annotation (https://www.cocreateusers.org/forum/forumdisplay.php?f=6)
-   -   Add elemt info (https://www.cocreateusers.org/forum/showthread.php?t=8335)

andrea 12-04-2018 06:16 AM

Add elemt info
 
it is possible to associate an annotation info to a text.
With me10 the command was used.

ADD_ELEM_INFO 'TR:WTtr:PTC_WM_LIFECYCLE_STATE:2:0:1:-102:1:0' SELECT GLOBAL PICK_VP_PNT 1 -50,10 CONFIRM END

Is it possible to do it directly in annotation?

Shaba 12-04-2018 10:54 PM

Re: Add elemt info
 
Prova questo

Code:

(OLI:SD-EXECUTE-ANNOTATOR-COMMAND :CMD \"ADD_ELEM_INFO 'TR:WTtr:PTC_WM_LIFECYCLE_STATE:2:0:1:-102:1:0' SELECT GLOBAL PICK_VP_PNT 1 -50,10 CONFIRM END\")
Anche se mi lascia perplesso che fai la selezione su un punto
E' una info da aggiungere per la compilazione del cartiglio?

andrea 12-06-2018 07:31 AM

Re: Add elemt info
 
sure that the "\" go there? gives me lisp error

in place of the coordinates "PICK_VP_PNT 1 -50,10" can I enter a variable that I calculate ??

there is an info to associate with a text already present on the cartouche completed by hand

Andy Poulsen 12-06-2018 01:21 PM

Re: Add elemt info
 
You are correct that the "\" causes errors in this case -- no "\" is needed.

You can certainly do this using the "ADD_ELEM_INFO ..." command, but (as you have discovered), it can be difficult to specify the object that you want to attach the info to.

Perhaps an easier way for you to do it is to use the lisp functions provided by the Annotation module. This will allow your dialog to allow the user to select an annotation item (part, line, etc) and then add the INFO to it using the command
(sd-am-add-info-attributes (list "Info 1" "Info 2" ) myobject)
or something like that. This would allow you to easily construct the info strings within your dialog and then attach them to the selected object.

Of course, if you want to use the ADD_ELEM_INFO approach, you can create that entire string using the (format ... ) command to build the string with the components you'd like, and then send that string to Annotation using the
(sd-execute-annotator-command :cmd mystring)
approach...

I hope this helps!

andy

andrea 12-06-2018 11:37 PM

Re: Add elemt info
 
what is the right writing to insert in :

(list "Info 1" "Info 2")
for my attribute
PTC_WM_LIFECYCLE_STATE

that I can not find the documentation for command :

sd-am-add-info-attributes
andl list "Info" !!

Andy Poulsen 12-07-2018 03:37 PM

Re: Add elemt info
 
You could do something like this:
Code:

(sd-am-add-info-attributes myobj (list "TR:WTtr:PTC_WM_LIFECYCLE_STATE:2:0:1:-102:1:0"))
Note that you will need to have myobj specified in your dialog, where myobj is an Annotation object.

The documentation for sd-am-add-info-attributes (and other related functions) can be found in the help.
Select "Documentation for Advanced Users"
Select "Integration Kit"
Select "Reference Manual"
Scroll down and select "Info Attributes" (under the Annotation Module heading)
Read about the functions and how they work.

I hope this helps!

andy

andrea 12-10-2018 05:48 AM

Re: Add elemt info
 
to indicate a "myobj" the text to which I want to add the info via the coordinates 2d ??

my text here I want to add the info has these 2D coordinates (always different from one drawing to another):

(setf pnt-x (gpnt2d_x (Nth 1 (sd-am-sheet-struct-corners (sd-am-inq-sheet (sd-am-inq-curr-sheet))))))
(setf pnt-y (gpnt2d_y (Nth 0 (sd-am-sheet-struct-corners (sd-am-inq-sheet (sd-am-inq-curr-sheet))))))

Andy Poulsen 12-11-2018 08:27 AM

Re: Add elemt info
 
Thanks for the additional information. I was thinking you needed to pick the object using the mouse -- since you can get the x and y points from the functions you listed, something like this might work:

Code:

(defun add-infos-to-sheet-text ()
  (let (pnt-x pnt-y cmdstr)
    (setf pnt-x (gpnt2d_x (Nth 1 (sd-am-sheet-struct-corners (sd-am-inq-sheet (sd-am-inq-curr-sheet))))))
    (setf pnt-y (gpnt2d_y (Nth 0 (sd-am-sheet-struct-corners (sd-am-inq-sheet (sd-am-inq-curr-sheet))))))
    (setf cmdstr (format nil "ADD_ELEM_INFO 'TR:WTtr:PTC_WM_LIFECYCLE_STATE:2:0:1:-102:1:0' select global texts (pnt_xy ~a ~a) confirm end" pnt-x pnt-y))
    (sd-execute-annotator-command :cmd cmdstr)
    )
  )

Then just call the add-infos-to-sheet function and it should work. NOTE: I haven't tested this, but the idea is correct.

Does this help?

andrea 12-17-2018 04:59 AM

Re: Add elemt info
 
Don't add info at this text ....
why ???

Wolfgang 12-17-2018 08:44 AM

Re: Add elemt info
 
Quote:

Originally Posted by andrea (Post 26170)
why ???

Figure out!

try this
Code:

(setf cmdstr (format nil "LINE (pnt_xy ~a ~a)" pnt-x pnt-y))
....as command string in Andy's function. It should start a 'rubbel line' at the start point. Is that a point with the right coordinates?

Does the Annotator exe report an error?
call (oli:sd-am-errros :clear) before your function call
call (display (oli:sd-am-errros :get_all)) after your function call

andrea 12-18-2018 05:57 AM

Re: Add elemt info
 
2 Attachment(s)
help me, this is the example to which I want to add my info to the text indicated in the image

This is the macro that I created, but does not add the info to the text

(defun add_infos_to_sheet_text ()
(let (pnt-x pnt-y cmdstr)
(setf pnt-x (- (gpnt2d_x (Nth 1 (sd-am-sheet-struct-corners (sd-am-inq-sheet (sd-am-inq-curr-sheet))))) 125.964))
(setf pnt-y (+ (gpnt2d_y (Nth 0 (sd-am-sheet-struct-corners (sd-am-inq-sheet (sd-am-inq-curr-sheet))))) 22.792))
(setf cmdstr (format nil "ADD_ELEM_INFO 'TR:WTtr:PTC_WM_LIFECYCLE_STATE:2:0:1:-102:1:0' select global texts (pnt_xy ~a ~a) confirm end" pnt-x pnt-y))
(oli:sd-execute-annotator-command :cmd cmdstr)
;;(DISPLAY(format nil "~a ~a" pnt-x pnt-y))
)
)

Andy Poulsen 01-03-2019 10:15 AM

Re: Add elemt info
 
Hi Andrea,

Thanks for including the drawing file and the image of the text you want to use -- both were very helpful!

It turns out that selecting texts using the SELECT method using a point (as we did) doesn't work, so we need to do something else.

It does work to pick the point directly, but it needs to be exact. I modified the function so it uses slightly different coordinates (both x and y) and use that point directly:
Code:

(defun add_infos_to_sheet_text ()
  (let (pnt-x pnt-y cmdstr)
    (setf pnt-x (- (gpnt2d_x (Nth 1 (sd-am-sheet-struct-corners (sd-am-inq-sheet (sd-am-inq-curr-sheet))))) 125.963))
    (setf pnt-y (+ (gpnt2d_y (Nth 0 (sd-am-sheet-struct-corners (sd-am-inq-sheet (sd-am-inq-curr-sheet))))) 22.7918))       
    (setf cmdstr (format nil "ADD_ELEM_INFO 'TR:WTtr:PTC_WM_LIFECYCLE_STATE:2:0:1:-102:1:0' global (pnt_xy ~a ~a) end" pnt-x pnt-y))
    (pprint (format nil "cmdstr: ~A" cmdstr))
    (oli:sd-execute-annotator-command :cmd cmdstr)
    )
  )

Please let me know how this works for you.

andrea 01-11-2019 12:19 AM

Re: Add elemt info
 
Perfect thank you very much

Andy Poulsen 01-22-2019 01:14 PM

Re: Add elemt info
 
You are very welcome! Glad to help!


All times are GMT -8. The time now is 08:45 AM.

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