Jump to content

change lineweight lisp correction please


jim78b

Recommended Posts

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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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