Jump to content
jim78b

change lineweight lisp correction please

Recommended Posts

jim78b

i have this lisp that in a block change all lineweight to byblock except layer 0.

but i tested if i make a block with only layer 0 , the lisp don't change layer 0 lineweight to byblock

is possible to adjust please?

 

(defun LM:unique  (l) (if l (cons (car l) (LM:Unique (vl-remove (car l) (cdr l))))))

(defun BB:setByBlock  (nam / blc blk)
  (setq blc (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
  (setq blk (vla-item blc nam))
  (vlax-for x  blk (if (= "0" (vlax-get-property x 'layer)) (vlax-put-property x 'lineweight acLnWtByBlock)))
)

(vl-load-com)

(defun c:bf ( / c_doc sel cnt obj col)

  (setq c_doc (vla-get-activedocument (vlax-get-acad-object)))
  (princ "\nSelect blocks : ")
  (setq sel (ssget '((0 . "INSERT"))))
  (cond (sel
          (repeat (setq cnt (sslength sel))
            (setq obj (vlax-ename->vla-object (ssname sel (setq cnt (1- cnt)))))
            (cond ( (= :vlax-true (vlax-get-property obj 'isdynamicblock))
                    (setq col (cons (vla-get-effectivename obj) col)
                          col (cons (vla-get-name obj) col)
                    )
                  )
                  (t  (setq col (cons (vla-get-effectiveName obx) col)))
            );end_cond
          );end_repeat
          (setq col (LM:unique col))
          (foreach x col (BB:setByBlock x))
        )
        ( (princ "\nNothing Selected"))
  );end_cond
  (vla-regen c_doc acActiveViewport)
  (princ)
);end_defun

 

Share this post


Link to post
Share on other sites
dlanorh

Try this, there was a variable mis-spelling in one branch of a condition statement

 

(defun LM:unique  (l) (if l (cons (car l) (LM:Unique (vl-remove (car l) (cdr l))))))

(defun BB:setByBlock  (nam / blc blk)
  (setq blc (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
  (setq blk (vla-item blc nam))
  (vlax-for x  blk (if (= "0" (vlax-get-property x 'layer)) (vlax-put-property x 'lineweight acLnWtByBlock)))
)

(vl-load-com)

(defun c:bf ( / c_doc sel cnt obj col)

  (setq c_doc (vla-get-activedocument (vlax-get-acad-object)))
  (princ "\nSelect blocks : ")
  (setq sel (ssget '((0 . "INSERT"))))
  (cond (sel
          (repeat (setq cnt (sslength sel))
            (setq obj (vlax-ename->vla-object (ssname sel (setq cnt (1- cnt)))))
            (cond ( (= :vlax-true (vlax-get-property obj 'isdynamicblock))
                    (setq col (cons (vla-get-effectivename obj) col)
                          col (cons (vla-get-name obj) col)
                    )
                  )
                  (t  (setq col (cons (vla-get-effectiveName obj) col)))
            );end_cond
          );end_repeat
          (setq col (LM:unique col))
          (foreach x col (BB:setByBlock x))
        )
        ( (princ "\nNothing Selected"))
  );end_cond
  (vla-regen c_doc acActiveViewport)
  (princ)
);end_defun

 

  • Like 1

Share this post


Link to post
Share on other sites
jim78b

thanks so much you are the best! best regards have a nice day dlanorh

Share this post


Link to post
Share on other sites
jim78b

sorry i try with a nested block all on layer 0 but don't change the 2nd block lineweight to byblock try to see my dwg

new block.dwg

Share this post


Link to post
Share on other sites
dlanorh

It wasn't originally designed for nested blocks. I'll have a look later today.

Share this post


Link to post
Share on other sites
jim78b

do me this favor thanks a lot

Share this post


Link to post
Share on other sites
dlanorh

OK, try this. It works in my test.

 

(defun LM:unique  (l) (if l (cons (car l) (LM:Unique (vl-remove (car l) (cdr l))))))

(defun BB:setByBlock  (nam / blc blk)
  (setq blc (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
  (setq blk (vla-item blc nam))
  (vlax-for x  blk
    (if (= "AcDbBlockReference" (vlax-get-property x 'objectname)) (BB:setByBlock (vlax-get-property x 'effectivename)))
    (if (= "0" (vlax-get-property x 'layer)) (vlax-put-property x 'lineweight acLnWtByBlock))
  )
)

(vl-load-com)

(defun c:bf ( / c_doc sel cnt obj col)

  (setq c_doc (vla-get-activedocument (vlax-get-acad-object)))
  (princ "\nSelect blocks : ")
  (setq sel (ssget '((0 . "INSERT"))))
  (cond (sel
          (repeat (setq cnt (sslength sel))
            (setq obj (vlax-ename->vla-object (ssname sel (setq cnt (1- cnt)))))
            (cond ( (= :vlax-true (vlax-get-property obj 'isdynamicblock))
                    (setq col (cons (vla-get-effectivename obj) col)
                          col (cons (vla-get-name obj) col)
                    )
                  )
                  (t  (setq col (cons (vla-get-effectiveName obj) col)))
            );end_cond
          );end_repeat
          (setq col (LM:unique col))
          (foreach x col (BB:setByBlock x))
        )
        ( (princ "\nNothing Selected"))
  );end_cond
  (vla-regen c_doc acActiveViewport)
  (princ)
);end_defun

 

  • Like 2

Share this post


Link to post
Share on other sites
jim78b

thanks a lot you are the best it is work, thanks for your patience have a nice evening

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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