Jump to content

; error: bad argument type: VLA-OBJECT nil


Recommended Posts

Posted

i have this lisp and i don't know wht it return bad argument nil if i select a block!

It put all on Layer 0  and set  lineweight on byblock

(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 (cond ( (= "0" (vlax-get-property x 'layer)) (vlax-put-property x 'lineweight acLnWtByBlock) (vlax-put-property x 'color 0))))
)

(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

 

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