Script to use Qselect

Script to use Qselect

Anonymous
Not applicable
3,335 Views
4 Replies
Message 1 of 5

Script to use Qselect

Anonymous
Not applicable

Hi,

 

Is there a way of using Qselect in a script?

 

I want to put all 4dia circles on a new layer. I can use Qselect to select the circles to do this manually. The problem I have is I need to do this on a lot of drawings. I was hoping to write a script and use ScriptPro to run it on all my drawings.

 

However when I use Qselect and look in the command line it doesn't list the options I have used to enable me to write a script...

 

Any help greatly appreciated

Thanks

M

0 Likes
3,336 Views
4 Replies
Replies (4)
Message 2 of 5

zph
Collaborator
Collaborator

You'll need to use 'ssget' something like this to get the circles:

 

(setq ss (ssget "X" (list '(0 . "CIRCLE")(cons 40 2))))

 

Then loop through the selection set (ss) and use entmod to change the layer of each entity.

 

EDIT: ...after posting I realized you asked for a solution using a script and I posted an AutoLISP example.

Message 3 of 5

Kent1Cooper
Consultant
Consultant

You could define a command in your acaddoc.lsp file, something like this:

 

(defun C:DOIT ()

  (command "_.chprop" (ssget "_X" '((0 . "CIRCLE") (40 . 2.0))) "" "_layer" "YourDesiredLayer" "")

)

 

Then run ScriptPro and have it simply call the DOIT command in each drawing.  Having that defined in acaddoc.lsp will mean that it's available in any drawing when opened.

 

[That particular way of defining the command will find only Circles whose diameter is exactly 4 units.  If there might be any variance in that, even very slight, compensation would need to be made.]

Kent Cooper, AIA
Message 4 of 5

Anonymous
Not applicable

Hi Kent,

 

Thanks for the info and sorry for not getting back earlier...

 

I have found the acaddoc.lsp file where about's would I insert your code? (I haven't written any LISP code before) File shown below...

 

;;;*-*TXT acad.lsp is loaded once, acaddoc.lsp is loaded for each
;;;       document, s::startup in any case is called after acaddoc.lsp
;;;       has been loaded
;
;;(if (= nil acad_helpdlg)
;; (progn
;;    (load "acadr15.lsp")
;;    (load (strcat (getvar "menuname") ".mnl"))
;;  )
;;)

;; code copied from acadmappend
(defun AcadMDocStart (/ )
  (if
    (cond
      ((/= T (load "gen/genbas0.lsp" T)) T)
      ((/= T (load "gen/genbas0.ll" T)) T)
      ((/= T
          (if ge0geniusdir
            (load (strcat ge0geniusdir "gen/genbas0.lsp") T)
            T
          )
        )
        T
      ); 
      ((/= T
          (if geniuspd
            (load (strcat (geniuspd) "gen/genbas0.lsp") T)
            T
          )
        ) 
        T
      ); 
      (T nil)       
    );cond
    (acadmstartup) 
    (progn
      (prompt "\nAcadM Error: file genbas0.lsp not loaded.")
      startup
    );progn
  );if 
);defun     

(if (= nil genlade)
  (progn
    (princ (load "gen/acadm.lsp" "\nError: acadm.lsp not loaded!"))
    ;;(if acadmappend (setq s::startup (acadmappend s::startup)))
    ;; DID 1375357 - don't modify s:startup it will be called to late
    ;; call acadmstartup here
    (AcadMDocStart)
  )
)

 

0 Likes
Message 5 of 5

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... 

I have found the acaddoc.lsp file where about's would I insert your code? ....


Either before or after what's already in the file.

Kent Cooper, AIA
0 Likes