Author Topic: Easy Macro Question  (Read 1547 times)

0 Members and 1 Guest are viewing this topic.

Ken

  • Guest
Easy Macro Question
« on: May 12, 2005, 02:11:14 PM »
I'm sure this will be easy for somebody. All I'm trying to do is set up a button macro that will allow me to draw a Pline with a width of 0.03 and then reset Plinewid to 0.0

Here's what I have so far, which works fine, except it doesn't reset the "plinewid" system variable back to 0.

^C^C(setvar "plinewid" 0.03)(command "_pline" pause)(setvar "plinewid" 0.00)

I'm sure it's something simple to activate the last setvar, but I can't figure it out. Or maybe somebody has a better way to set up this macro to do what I want? Any help or ideas will be appreicated.

Ken

ronjonp

  • Needs a day job
  • Posts: 7531
Easy Macro Question
« Reply #1 on: May 12, 2005, 03:08:56 PM »
Try modifying this to work for you. To reset the value you have to have the macro end successfully....(command "_pline" pause) this only allows for one pick. You might wanna try (command "_pline" pause pause) this will draw one segment then reset the width to 0.


Code: [Select]
(defun c:te (/  u-plinegen u-clayer u-plinewid *error* drawpline)         ;Used for inserting bubbler laterals


;_____________________________
;Error function
;_____________________________

(defun *error* (msg)
   (if
      (not
        (member
          msg
          '("console break" "Function cancelled" "quit / exit abort" "")
        )
      )
       (princ (strcat "\nError: " msg))
    ) ; if
(setvar 'plinegen u-plinegen)
(setvar 'clayer u-clayer)
(setvar 'plinewid u-plinewid)
    (princ)
  ) ;end error function


;_____________________________
;Function to draw polyline
;_____________________________

(defun drawpline (/)
  (command "_.pline")
  ;;   repeat a point input until Enter
  (if (while (> (getvar "CMDACTIVE") 0)
(command pause)
      )
   (*error* "")
  )
)

;_____________________________
;Get User Variables
;_____________________________

(setq u-plinegen (getvar 'plinegen)
u-clayer   (getvar 'clayer)
u-plinewid (getvar 'plinewid)
)

;_____________________________
;Set layer draw pline
;_____________________________


(if (tblsearch "layer" "0280-tree-lateral")
(command "-layer" "thaw" "0280-tree-lateral" "on" "0280-tree-lateral" "")
)
      (setvar 'plinegen 1)
      (setvar 'plinewid (* (getvar "dimscale") 0.025))
      (command "_.-Layer" "_Make" "0280-tree-lateral" "_L" "hidden2" "" "_Color" "4" "" "")
   (drawpline)
   (setvar 'plinegen u-plinegen)
   (setvar 'clayer u-clayer)
   (setvar 'plinewid u-plinewid)
  )


Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Ken

  • Guest
Easy Macro Question
« Reply #2 on: May 12, 2005, 04:07:59 PM »
ronjonp,

I tried adding the additional pause to the macro, but no change. It will let me draw any number of segments with the new width, but after ending the pline command, it doesn't change back the plinewid variable to 0.

I was hoping to get by without a full LISP routine, but your code looks great, so if I need to, I'm sure I can modify it to work.

Thanks.

Ken