Jump to content

Simple lisp - how to remove unncessary steps/clicks


Recommended Posts

Posted

Hi,

 

I am new to autolisp and created a lisp which help me automate 1 of my daily task.

 

Here is the code of the lisp.

(defun C:test (/);
(while (setq P1 (getpoint "\nSpecify insert point for arrow: "))
(command ".-Insert" "BLOCKA" P1 "1" "1" pause) ;insert block
(command "ARC" P1 pause pause) ; create arc
(command ".-Insert" "BLOCKB" pause "1" "1" "0") ; insert block
(command "EXPLODE" (ssget "L" )) ;explode object )
(command "_ddedit" (ssget "L" ))(command) ;Edit text
(command ".move" (ssget "L") "" pause pause));Edit number
(princ)    
)

i have also attached the image and cad file for more understanding.

 

 

What I am thinking that numbers of steps can be reduced from the above script for more efficient working.

For eg:

- 2nd point of arc may be automatically pick the center point of the arrow.

- After placing and editing "blockb" the move of the object should come rather then picking/selecting up the number you just entered.

 

So i request to people in this forum who can highlight or provide solution for them.

 

Let me know if you need any other information or need to be more clear.

 

Regards

nura

TEST.JPG

TEST.dwg

Posted

Try

 

(defun C:test (/ P1 P2 P3)
   (while (setq P1 (getpoint "\nSpecify insert point for arrow: "))
       (command "_-Insert" "BLOCKA" P1 "1" "1" pause ) 
       (setq P2 (cadr (grread T)))
       (setq P3 (polar P1 (angle P1 P2) 2.2453))
       (command "_pline" P1 P3 "_A" pause "")
       (command "_-Insert" "BLOCKB" pause "1" "1" "0")
       (command "_EXPLODE" "_L")
       (command "_ddedit" "_L" "")
       (command "._move" "_L" "" pause pause)
   )
   (princ)    
)

Posted

Hi GP

 

you lisp work for me to reduce a number of step.

However is there any possibility to autopick the base point of displacement to center(middle) of the text so that another single can be reduced.

 

Anyway thanks for your effort.

 

and please explain if you can, so that i can learn from it. what does "grread T" and "2.2453" mean for here?

 

 

Best Regards,

nura

 

Try

 

(defun C:test (/ P1 P2 P3)
   (while (setq P1 (getpoint "\nSpecify insert point for arrow: "))
       (command "_-Insert" "BLOCKA" P1 "1" "1" pause ) 
       (setq P2 (cadr (grread T)))
       (setq P3 (polar P1 (angle P1 P2) 2.2453))
       (command "_pline" P1 P3 "_A" pause "")
       (command "_-Insert" "BLOCKB" pause "1" "1" "0")
       (command "_EXPLODE" "_L")
       (command "_ddedit" "_L" "")
       (command "._move" "_L" "" pause pause)
   )
   (princ)    
)

Posted

In order not to upset your routine ...

 

(defun C:test (/ P1 P2 P3 P4)
   (while (setq P1 (getpoint "\nSpecify insert point for arrow: "))
       (command "_-Insert" "BLOCKA" P1 "1" "1" pause ) 
       (setq P2 (cadr (grread T)))
       (setq P3 (polar P1 (angle P1 P2) 2.2453))
       (command "_pline" P1 P3 "_A" pause "")
       (command "_-Insert" "BLOCKB" pause "1" "1" "0")
       (command "_EXPLODE" "_L")
       (command "_ddedit" "_L" "")
       (command "_justifytext" "_L" "" "MC" "")
       (setq P4 (cdr (assoc 11 (entget (entlast)))))
       (command "._move" "_L" "" P4 pause)
   )
   (princ)    
)

Posted

(cadr (grread T)) -> Capture the cursor position on the screen.

 

393.jpg

Posted

thank to you and cad tutor forum.

 

(cadr (grread T)) -> Capture the cursor position on the screen.

 

[ATTACH=CONFIG]39111[/ATTACH]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...