help to refine my lisp code

help to refine my lisp code

thecadworker
Explorer Explorer
1,424 Views
8 Replies
Message 1 of 9

help to refine my lisp code

thecadworker
Explorer
Explorer

Hi,

I have made a code to select the text, set the layer current, move the text and draw an arrow to its position from its original position and in the layer of the text. The code I have asks for the selection twice.

Please let me know how to reduce the selection to 1 time.

 

(Defun c:Tpx (/ pt1 pt2) ;
(WHILE T
(setvar "cmdecho" 0)
(setq entlist (entget (car (entsel "\nSelect object: "))))
(setvar "clayer" (cdr (assoc 8 entlist)))
(setq txt (car (entsel "\nSelect object: ")))
(if txt
(progn
(setq elist (entget txt)); entity list
(setq IP (cdr (assoc 10 elist))); Insertion Point
); progn
); if
(setq IP2 (getpoint "\nPick Next point: "))
(command "move" txt "" ip IP2 "")
(command "_.leader" IP IP2 "_a" "" "_n")
)
)

Accepted solutions (1)
1,425 Views
8 Replies
Replies (8)
Message 2 of 9

ВeekeeCZ
Consultant
Consultant

OK

also, now you can terminate the routine by RT click (as any other command)

 

 

 

 

(Defun c:Tpx (/ *error* lay ent pnt pnt2)
  
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if lay (setvar 'clayer lay))
    (princ))
  
  
  (setq lay (getvar 'clayer))
  
  (while (setq ent (car (entsel "\nSelect text: ")))
    
    (setvar 'clayer (cdr (assoc 8 (entget ent))))
    (setq pnt (trans (cdr (assoc 10 (entget ent))) 0 1))
    (command "_.move" ent "" "_non" pnt pause)
    (setq pnt2 (getvar 'lastpoint))
    (command "_.leader" "_non" pnt "_non" pnt2 "_a" "" "_n")
    )
  
  (*error* "end")
  )

 

 

 

Message 3 of 9

thecadworker
Explorer
Explorer
Thanks for this help, Also I need to increase the text height to 2.0.
0 Likes
Message 4 of 9

ВeekeeCZ
Consultant
Consultant
Accepted solution

ok

 

(Defun c:Tpx (/ *error* lay ent pnt pnt2)
  
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if lay (setvar 'clayer lay))
    (princ))
  
  
  (setq lay (getvar 'clayer))
  
  (while (setq ent (car (entsel "\nSelect text: ")))
    
    (setvar 'clayer (cdr (assoc 8 (entget ent))))
    (setq pnt (trans (cdr (assoc 10 (entget ent))) 0 1))
    (setpropertyvalue ent "Height" 2)
    (command "_.move" ent "" "_non" pnt pause)
    (setq pnt2 (getvar 'lastpoint))
    (command "_.leader" "_non" pnt "_non" pnt2 "_a" "" "_n")
    )
  
  (*error* "end")
  )
 

 

Message 5 of 9

fbyfatih
Contributor
Contributor

Why did you use trans in this code? It works fine without it

Message 6 of 9

ВeekeeCZ
Consultant
Consultant

@fbyfatih 

 

If you never use UCS you don't need it.

Message 7 of 9

WeTanks
Mentor
Mentor

Is it possible to add a frame to the text after the text is moved?

We.Tanks

EESignature

A couple of Fusion improvement ideas that could your vote/support:
図面一括印刷

0 Likes
Message 8 of 9

ВeekeeCZ
Consultant
Consultant

@WeTanks wrote:

Is it possible to add a frame to the text after the text is moved?


 

It's fairly easy if it's MTEXT. Is it?

0 Likes
Message 9 of 9

diagodose2009
Collaborator
Collaborator

Please .. Hello Expert or AutoCad.

Exists one site with many CAD'programs for CAd - online and Vlide-online for many test/s of our LISP'programs, 

The loginUsers cannot open and save the Drawings but they can test VLIDE and Lisp-programs and ARX?

0 Likes