Jump to content

Qleader


flowerrobot

Recommended Posts

Can some one please tell this moron why this code only works 70% of the time.

Its so simple yet, i can not make it work consistantly

 

(DEFUN C:LE()
   (command ".LAYER" "s" "DIM" "")
   (command ".linetype" "s" "bylayer"\\)
   (command ".color" "bylayer")
   (COMMAND ".QLEADER" )
   (princ)
)

Link to comment
Share on other sites

(defun c:le (/ oldlay)
   (setq oldlay (getvar "clayer"))
   (setvar "clayer" "DIM")
   (command "-linetype" "s" "bylayer" "")
   (command "-color" "bylayer")
   (command "_qleader")
   (setvar "clayer" oldlay)
   (princ)
)

I tried using:

 

(command "_qleader")
(while (> (getvar 'CmdActive) 0) (command pause))
(princ)

But ACAD gets stuck in an endless loop....

Link to comment
Share on other sites

Can some one please tell this moron why this code only works 70% of the time.

Its so simple yet, i can not make it work consistantly

 

(DEFUN C:LE()
   (command ".LAYER" "s" "DIM" "")
   (command ".linetype" "s" "bylayer"[color="Red"]\\ <<what is this?[/color])
   (command ".color" "bylayer")
   (COMMAND ".QLEADER" )
   (princ)
)

 

 

Make sure that the layer exists....other than that looks ok

Link to comment
Share on other sites

Make sure that the layer exists(command ".linetype" "s" "bylayer"\\

It does exist, but i did have it as

"m" (make layer) instead of "s" (set layer),

but the same problem existed hence me changing it to current

, not sure what you mean "what is this"

its to ensure that the line is set by layer, as some of the companys stupied lisps alter my set up, so i place color and linetype in for ease.

Link to comment
Share on other sites

I think:

 

(defun c:le()
 (if(tblsearch "LAYER" "DIM")
   (setvar "CLAYER" "DIM")
   (command "_.layer" "_m" "DIM" "")
   ); end if
 (mapcar 'setvar '("CELTYPE" "CECOLOR")'("BYLAYER" "BYLAYER"))
 (command "_.qleader")
 ); end of c:le

 

You need to check layer existance in "LAYER" table and remove finish (princ) for command continue.

 

You may be interesting such code with command-reactor. It will automatically swich your layer and color afrer "QLEADER" command. Use REAON command to swich on reactor and REAOFF to swich off.

 

(defun c:reaon()
(vl-load-com)
 (if(not com:react)
   (progn
     (setq com:react
  (vlr-command-reactor nil
    '((:vlr-commandWillStart . ComReactBegin)
      (:vlr-commandEnded . ComReactEnd)
      (:vlr-commandCancelled . ComReactCancel))))
     (princ "\n<<< Command reactor Switched ON >>>")
      ); end progn
     ); end if
   (princ)
   ); end of c:reaon

 (defun c:reaoff()
   (if com:react
     (progn
      (vlr-Remove com:react)
      (setq com:react nil)
      (princ "\n<<< Command reactor Switched OFF >>> ")
      ); end progn
     ); end if
   ); end of c:reaoff

 (defun ComReactBegin(react args / comLst nLay)
   
   (setq comLst '((("DIM" 256)"QLEADER"))); end setq
   
   (foreach itm comLst
     (if(member(car args)itm)
(progn
  (if(not(tblsearch "LAYER"(caar itm)))
    (progn
     (setq nLay(vla-Add(vla-get-Layers
        (vla-get-ActiveDocument
	  (vlax-get-acad-object)))(caar itm)))
     (vla-put-Color nLay(cadar itm))
     (setq com:resFlg T)
     ); end progn
    ); end if
   (setq com:oldLay(getvar "CLAYER")
	 com:resFlg T)
   (setvar "CLAYER"(caar itm))
  ); end progn
); end if
     ); end foreach
   (princ)
   ); end of ComReactBegin

 (defun ComReactEnd(react args)
   (if com:resFlg
     (progn
(setq com:resFlg nil)
       (setvar "CLAYER" com:oldLay)
      ); end progn
     ); end if
   (princ)
   ); end of ComReactEnd

 (defun ComReactCancel(react args)
   (if com:resFlg
     (progn
(setq com:resFlg nil)
       (setvar "CLAYER" com:oldLay)
      ); end progn
     ); end if
   (princ)
   ); end of ComReactCancel

(princ "\nType REAON to switch-on and REAOFF switch-off command reactor ")

 

You can modify command list in variable comLst. It structure is:

 

'((("Layer1" Color1)"Command1" "Command2" ...))(("Layer2" Color2)"Command3" "Command4" ...)) ... )

 

For example:

 

(setq comLst '(
	(("Dimensions" 6)"QDIM" "DIMLINEAR" "QLEADER" "DIMCONTINUE"
	    "DIMDIAMETER" "DIMANGULAR" "DIMRADIUS" "DIMBASELINE"
	    "DIMALIGNED")
	(("Text" 1) "MTEXT" "DTEXT" "TEXT")
            )
      ); end setq

 

I can add Linetype if you need.

Link to comment
Share on other sites

I THINK I LOVE YOU!!!

ive seen an increasing amount of reactor comments or recent.

and was going to look more into them when things slowed down.

 

would you be able to reference me any places to read up on it, if you have some, other wise im v's my enemy google

Link to comment
Share on other sites

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