Author Topic: Paste not allowed, not sticking..[SOLVED..]  (Read 5656 times)

0 Members and 1 Guest are viewing this topic.

ScottMC

  • Newt
  • Posts: 193
Paste not allowed, not sticking..[SOLVED..]
« on: April 06, 2023, 09:13:17 AM »
How do I enable pasting coords into this [Lee's] converter?
Picking works fine.
Examples:

 Pick Point for Coords to Use/Convert: 27.02485,12.61196,0

There's times when the conversion would be handy. THANKS
                                                                           \/   pasted
 Pick Point for Coords to Use/Convert: (41.9014 30.2182 0.0)
Can't reenter LISP.
Invalid point.

Code: [Select]

(defun c:xzz ()
(setq mlst (getpoint "\n Pick Point for Coords to Use/Convert: "))
(setq mlst (list (rtos (car mlst))(rtos (cadr mlst))(rtos (caddr mlst))))
 
 ;; List to String  -  Lee Mac
;; Concatenates each string in a supplied list, separated by a given delimiter
;; lst - [lst] List of strings to concatenate
;; del - [str] Delimiter string to separate each item

    (defun LM:lst->str ( lst del / str )
        (setq str (car lst))
        (foreach itm (cdr lst) (setq str (strcat str del itm)))
        str
    )

(princ (LM:lst->str mlst ","))

(princ)
)

« Last Edit: May 03, 2023, 06:58:57 PM by ScottMC »

danAllen

  • Newt
  • Posts: 133
Re: Paste not allowed, not sticking..
« Reply #1 on: April 06, 2023, 11:27:22 AM »
Make a command variant that accepts a string and use read to convert to list:

: (setq t1 (getstring "paste here: "))
paste here: (41.9014 30.2182 0.0)
"(41.9014 30.2182 0.0)"
: (read t1)
(41.9014 30.2182 0.0)


57gmc

  • Bull Frog
  • Posts: 366
Re: Paste not allowed, not sticking..
« Reply #2 on: April 06, 2023, 12:41:02 PM »
Your lisp worked for me. Just don't try pasting the coordinates to the drawing area. Paste them into the command line.

Also, for readability, don't include Lee's defun inside your defun. It should be separate.

**Sorry, when I pasted, I didn't include the parens. That's what causes the error, forcing it to evaluate the lisp expression. You need to enter the coords as you would normally, as coordinates, not a lisp expression. How are you copying the point? from a list somewhere?
« Last Edit: April 06, 2023, 12:49:25 PM by 57gmc »

ScottMC

  • Newt
  • Posts: 193
Re: Paste not allowed, not sticking..
« Reply #3 on: April 06, 2023, 06:07:26 PM »
Just seems it'd be easier to have a converter to do the work than changing however many lsp's I have.
Here's a link to just one which does just what needs conversion after in order to use during a command.. 
https://www.theswamp.org/index.php?topic=48726.msg538264#msg538264
As u'll see, understandably LSP programmers can/do choose not to add the rest of the desired pgm when posting code.
For me, it's exciting to work this another way instead of having to modify the many with this style of results..
As a subroutine, eventually I'll probably add this solution as time allows.

57gmc

  • Bull Frog
  • Posts: 366
Re: Paste not allowed, not sticking..
« Reply #4 on: April 06, 2023, 06:17:18 PM »
Just seems it'd be easier to have a converter to do the work than changing however many lsp's I have.
Here's a link to just one which does just what needs conversion after in order to use during a command.. 
https://www.theswamp.org/index.php?topic=48726.msg538264#msg538264
As u'll see, understandably LSP programmers can/do choose not to add the rest of the desired pgm when posting code.
For me, it's exciting to work this another way instead of having to modify the many with this style of results..
As a subroutine, eventually I'll probably add this solution as time allows.
You lost me? I thought you were talking about pasting a string representing a point at the prompt to pick a point. I was asking about where you obtain the string. I don't know what converter you're talking about.

ScottMC

  • Newt
  • Posts: 193
Re: Paste not allowed, not sticking..
« Reply #5 on: April 06, 2023, 07:49:32 PM »

57gmc

  • Bull Frog
  • Posts: 366
Re: Paste not allowed, not sticking..
« Reply #6 on: April 07, 2023, 10:15:22 AM »
Well, that sub is working as designed. Do you still have a problem?

danAllen

  • Newt
  • Posts: 133
Re: Paste not allowed, not sticking..
« Reply #7 on: April 07, 2023, 10:52:45 AM »
In your XZZ lisp, set (INITGET 128) to allow for arbitrary input. After getting a point (a list), or pasting a string, test what type of data MLST is using TYPE. If it is a string, then use READ to convert the string to a list which Lee's function will accept.

ScottMC

  • Newt
  • Posts: 193
Re: Paste not allowed, not sticking..
« Reply #8 on: April 07, 2023, 03:36:40 PM »
Here's a re-run..
  There's times when I'll use a lsp to get info(coords) and
in the process would be convient to have a subroutine to
work transparent and take the coords acquired and convert
them into cmd-line a usable x,y,z. Here's a small one I use to
get coords from the mouse click on screen:

Code: [Select]
(defun c:xz ( / ptx pty ptz pt) ;; Gets coords from pick
(setq pt (getpoint "\n (T) Coords + ")) ;
(princ pt) ;; shows pre-convert
   (setq ptx (rtos (car pt) 2 5)
         pty (rtos (cadr pt) 2 5)
         ptz (rtos (caddr pt) 2 5)
    )
(princ (strcat "    " ptx "," pty "," ptz))
(princ)
)




 Yet.. still haven't figured how to paste (x y z) coords into it
for the conversion desired.
« Last Edit: April 08, 2023, 06:27:46 PM by ScottMC »

danAllen

  • Newt
  • Posts: 133
Re: Paste not allowed, not sticking..
« Reply #9 on: April 07, 2023, 04:17:34 PM »
I don't understand the workflow that you are trying to achieve. You can have a routine save a point (as a list), to a global variable, then at the command line use exclamation point to use the variable value, example below just typing at the command line. I believe lisp routines can't work that way. Also I would be careful with your XZ lisp because you are converting actual points to a rounded number string. Perhaps you want to lose precision, but normally I would not want to.

: (setq pt1 (getpoint))
(3455.24229849009 3128.86653350467 0.0)
: (setq pt2 (getpoint))
(3487.63329459077 3137.63115597897 0.0)
: L
ENTER to use last point/Follow/<Start of line>: !pt1
(3455.24229849009 3128.86653350467 0.0)
ENTER to use last point/Follow/<Start of line>:
Angle/Length/Undo/<End point>: !pt2
(3487.63329459077 3137.63115597897 0.0)
Angle/Length/Undo/<End point>:
Angle/Length/Follow/Undo/<End point>:


You can also use DosLib to save strings to the windows clipboard for pasting. I would not use for point data because you will likely lose precision. For example I use this for quickly measuring pline area and pasting as text into CAD or into Excel, automatically formatted with rounding, comma, and suffix, example  "1,234 SF"
« Last Edit: April 07, 2023, 04:21:16 PM by danAllen »

ScottMC

  • Newt
  • Posts: 193
Re: Paste not allowed, not sticking..
« Reply #10 on: April 07, 2023, 06:07:17 PM »
Hmm.. the coords are not from getpoint but rather pasted/princ.ed from another (T) command.
[ot - my choice is Ditto for clpboard]

ScottMC

  • Newt
  • Posts: 193
Re: Paste not allowed, not sticking..
« Reply #11 on: April 10, 2023, 08:35:00 AM »
Found a variable with the format. Still it's not the tool/variable when it's needed.

Command: r                                                         < begin
RECTANGLE
Specify first corner point or [Chamfer/Elevation/Fillet/Thickness/Width]:
Specify other corner point:                                       < finish rectangle
Command: l                                                       
LINE Specify first point: 'lastpoint       < gets the second point coords from the rectangle
                                                       \/   the format is good but.. doesn't proceed using it
>>Enter new value for LASTPOINT <11.72239,11.10465,0.00000>:
                                                       \/  used it by copying from cmd and..
Resuming LINE command.       \/  pasting it
Specify first point: 11.72239,11.10465,0.00000

Still must be a way to convert easier. If it was a needed point then using "@" or 'enter' also works.
Must be changing each tool to save the coords/(X Y Z) into a USERR var would work as point.....

Command: (setq USERR1 "(1 2 3)")
"(1 2 3)"

Command: !USERR1
"(1 2 3)"

Command: (princ userr1)
(1 2 3)"(1 2 3)"
« Last Edit: April 10, 2023, 08:40:28 AM by ScottMC »

danAllen

  • Newt
  • Posts: 133
Re: Paste not allowed, not sticking..
« Reply #12 on: April 10, 2023, 10:43:39 AM »
I don't recommend using global variables with names similar to the system variables USERR1 (for reals), and USERS1 (for strings), it can confuse someone (like me).
Just FYI, USERR1 is a real (like  1234.456) system variable, it won't save strings or points.

As I posted earlier, you can save a point list such as (list 0.0 1.2 0.0) or '(0.0 1.2 0.0) to a regular global variable and then pass that variable to the command line with exlamation point, example !T1 (or if you must !USERR1)

Also FYI the LASTPOINT system variable is a list:
: (type (getvar "lastpoint"))
LIST


If you are always obtaining the point to want to reuse with copying the command history (as a string) you could write a lisp command that converts a clipboard string "point" into an actual point list. The command would need to be invoked transparently via 'YOURCOMMAND. I believe lisp commands can be set to work transparently using vlax-add-cmd. See https://www.cadtutor.net/forum/topic/6354-is-it-possible/?do=findComment&comment=51593

Again I don't recommend using strings to copy past a point because the string will always lose some significance from the higher precision stored in autocad entities.
« Last Edit: April 10, 2023, 12:30:57 PM by danAllen »

57gmc

  • Bull Frog
  • Posts: 366
Re: Paste not allowed, not sticking..
« Reply #13 on: April 10, 2023, 12:24:20 PM »
Found a variable with the format. Still it's not the tool/variable when it's needed.

Command: r                                                         < begin
RECTANGLE
Specify first corner point or [Chamfer/Elevation/Fillet/Thickness/Width]:
Specify other corner point:                                       < finish rectangle
Command: l                                                       
LINE Specify first point: 'lastpoint       < gets the second point coords from the rectangle
                                                       \/   the format is good but.. doesn't proceed using it
>>Enter new value for LASTPOINT <11.72239,11.10465,0.00000>:
                                                       \/  used it by copying from cmd and..
Resuming LINE command.       \/  pasting it
Specify first point: 11.72239,11.10465,0.00000

Still must be a way to convert easier. If it was a needed point then using "@" or 'enter' also works.
Must be changing each tool to save the coords/(X Y Z) into a USERR var would work as point.....

Command: (setq USERR1 "(1 2 3)")
"(1 2 3)"

Command: !USERR1
"(1 2 3)"

Command: (princ userr1)
(1 2 3)"(1 2 3)"

Are you running the RECT command and then the LINE command, literally using copy/paste to provide a point to the LINE command? Or are you trying to use lisp to code a solution? If the first is true, why don't you use running osnaps with the LINE command and simply snap to the rectangle's corner? If the second is true, then you could use the (getpoint) function to prompt the user for the line's first point and still snap to the rectangle. Like Dan mentioned, copy/paste is not a good practice/solution.

danAllen

  • Newt
  • Posts: 133
Re: Paste not allowed, not sticking..
« Reply #14 on: April 10, 2023, 12:56:19 PM »
You could also write a simple lisp that is called by a shortcut key or mouse menu to save a point to global variable, then a second lisp returns that variable for a command.

For example my CUI has this short lisp call to return the drawing INSBASE variable to a command.


      <MenuMacro UID="MM_00066">
        <Macro>
          <Name>Dwg Insertion Base Pt</Name>
          <Command>non (getvar "insbase")</Command>
        </Macro>
      </MenuMacro>


Example code:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:pt1save ()
  2.   (pt1save)
  3.   (princ)
  4. )
  5. (defun pt1save ()
  6.   (setq USER_PT1 (getpoint "\nSelect point to save to global variable: "))
  7.   (princ USER_PT1)
  8. )
  9.  
  10. (defun pt1return ()
  11.   USER_PT1
  12. )
  13.  

Type PT1SAVE to save a point you select. (Not copying history text.)

At any cad command you can type (pt1return)  to retrieve the saved point. There may be a way to make the lisp a transparent command such as 'PT1, but I don't know how.