Jump to content

Recommended Posts

Posted

I want to update this lisp

 

;to select all dimensions

(defun c:dms(/ dimsel)

(setq dimsel(ssget "x" '((0 . "DIMENSION"))))

(command "_PSELECT" "_p" "")

(PRINC)

)

 

What I want is to add another condition "when layer is ON" because this lisp select all dimension even in OOF layers.

 

I got the reason (when value of DXF code 62 is negative) but couldn't add the condition.

 

Could _SELECT be used in state of _PSELECT?

Because PSELECT command needs properties palate opened at least one time.

Posted

How about;

 

(defun c:dms nil
 (sssetfirst nil (ssget "_X" '((0 . "DIMENSION"))))
 (princ))

Posted

Still select dimensions in OFF layers

Posted

Hows this?

 

(defun c:dms (/ ss)

 (if (setq ss (ssget "_X" '((0 . "DIMENSION"))))
   
   (sssetfirst nil
     (last
       (mapcar
         (function
           (lambda (x)
             (if (minusp
                   (cdr
                     (assoc 62
                       (entget
                         (tblobjname "LAYER"
                           (cdr
                             (assoc 8
                               (entget x)
                             )
                           )
                         )
                       )
                     )
                   )
                 )
               (ssdel x ss) ss
             )
           )
         )
         (mapcar
           (function cadr)
             (ssnamex ss)
         )
       )
     )
   )
 )             
                
 (princ)
)

Posted

At the risk of being shown up by Lee or someone else... Here is one way to do it...

 


;to select all dimensions
(defun c:dms(/ dimsel ent lst lay col newss i)
(setq dimsel(ssget "x" '((0 . "DIMENSION"))) i 0 newss (ssadd))
(repeat (sslength dimsel)
 (setq ent (ssname dimsel i))
 (setq lst (entget ent))
 (setq lay (cdr (assoc 8 lst)))
 (setq lyr (entget (tblobjname "layer" lay)))
 (setq col (cdr (assoc 62 lyr)))
 (if (not (minusp col))
   (ssadd ent newss)
 )
 (setq i (1+ i))
)  
(command "_PSELECT" newss "")
(PRINC)
)

 

If you had thousands and thousands of entities and layers, you would probably want to add some more code that you can avoid checking the same layer twice.

 

At the risk of being shown up by Lee...

See what I mean?

Posted

Another:

 

(defun c:dms (/ str tdef)
 (setq str "")

 (while (setq tdef (tblnext "LAYER" (not tdef)))
   (if (minusp (cdr (assoc 62 tdef)))
     (setq str (strcat str (chr 44) (cdr (assoc 2 tdef))))))

 (sssetfirst nil (ssget "_X" (list (cons 0 "DIMENSION")
                                     (cons -4 "<NOT")
                                       (cons 8 (substr str 2))
                                     (cons -4 "NOT>"))))
 (princ))
                                   

 

Originally Posted by rkmcswain viewpost.gif

At the risk of being shown up by Lee...

See what I mean?

 

Sorry dude :wink:

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