Jump to content

Autolisp to draw polyline arc and spline ?


Recommended Posts

Posted

Hello,

Looking for an autolisp that draws continously polyline and with right clic dropdown list allow to change to arc or spline .

Posted

If I understand correctly and if you have DosLib installed, try this

(defun c:test (/ cmd_list cmd p1)
 (setq cmd_list '("Pline" "Arc" "Spline" "Exit"))
 (while
   (and
     (setq cmd (dos_popupmenu cmd_list))
     (/= cmd 3)
     )
   (command (nth cmd cmd_list))
   (if p1 (command p1))
   (while (= 1 (getvar 'cmdactive))
     (command "\\")
   )
   (setq p1 (getvar 'lastpoint))
 )
 (princ)
)

Posted

Hello Stefan BMR ,

I tried to use your code with my autolisp custom commands it gives "unknown command press "F1" for help" ,to your knowledge the autolisps are already loaded and my custom commands run when launched from my custom toolbar.Any help.

Posted

Hi fathihvac

It must be some misspelling in your loading routine or in macro assignment.

Please double check lisp file name, command name and macro command. I can not suspect anything else going wrong.

Posted

I try to replace existing command with other but circle only work. Does it got any limitation or need to rewrite something in program? It is actually very handy.

Posted
I try to replace existing command with other but circle only work. Does it got any limitation or need to rewrite something in program? It is actually very handy.

 

Try this Marek:

(defun c:test ( / cmd lpt lst )
   (setq lst '("Pline" "Arc" "Spline" "Circle" "Exit"))
   (while
       (and
           (setq cmd (dos_popupmenu lst))
           (/= "EXIT" (strcase (nth cmd lst)))
       )
       (command (nth cmd lst))
       (if lpt (command lpt))
       (while (= 1 (getvar 'cmdactive))
           (vl-cmdf "\\")
       )
       (setq lpt (getvar 'lastpoint))
   )
   (princ)
)

Posted

Hi MD

 

OP specifically asks to draw continuously some specific objects. In this particularly case, each command demands a point as a first input.

If you try commands that need something else as a first input, i.e. select object, then obviously is not going to work.

 

You may try this, but do not try to call Text, Mtext, Save, Open etc. USE IT ON YOUR OWN RISK.

(defun c:test (/ cmd_list cmd cmd_name)
 (setq cmd_list '("Line" "Move" "Copy" "Offset" "Trim" "Erase" "Exit")) ; don't forget to put "exit" option
 (while
   (and
     (setq cmd (dos_popupmenu cmd_list))
     (setq cmd_name (strcase (nth cmd cmd_list)))
     (not (eq cmd_name "EXIT"))
     )
    (if
      (not (wcmatch cmd_name "*TEXT,*DIM*,*LEADER,OPEN,SAVE"))
       (progn
         (command cmd_name)
         (while (= 1 (getvar 'cmdactive))
           (command "\\")
           )
         )
       )
    )
 (princ)
 )

Posted

Add all command form Lee and Stefan routines into one. Another speed increase for me.

Nice thing, this drop down stay at cursor, no more running for icon or typing.

-Is there any particular reason why not to use Command mentioned by Stefan?

Another thing: try to call lisp from inside this routine and it fail. Is it supporting only native Autocad commands?

Maybe I want to much...

Posted

Marek

 

I just tried Mtext command and my screen filled up with "\" and I could exit only by pressing escape. I thought this may cause AutoCAD to stuck and that's why I say not to use some commands, especially those who prompt for string. I didn't try Open or Save but, just in case, I added them on "forbidden" list. Maybe I overreacted.

 

About calling another lisp, try this

(defun c:test (/ cmd_list cmd)
 (setq cmd_list '("Line"  "Pline" "Spline" "Arc"    "Circle" "Ellipse"
                  "Erase" "Trim"  "Extend" "Offset"
                  "" ; separator. Do not remove it. Do not add another separator.
                     ; Add autocad native commands only above separator
                     ; Add lisp defined command only after separator
                  "Lisp1" "Lisp2")
       )
 (if
   (setq cmd (dos_popupmenu cmd_list))
   (if
     (< cmd (vl-position "" cmd_list))
     (command (nth cmd cmd_list))
     (eval (read (strcat "(C:" (nth (1+ cmd) cmd_list) ")")))
   )
 )
 (princ)
 )

You will notice it is not working exactly like the other one. Maybe it can be improved, but for now just try it and tell me what you think.

Posted

No need for improvement for now. Work very well.

Sometime I got work that require same set of commands, like repeating sequences that where it becoming handy.

Thank you for it.

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...