bad argument type: VLA-OBJECT NIL...exasperated trying to fix

bad argument type: VLA-OBJECT NIL...exasperated trying to fix

Anonymous
Not applicable
1,682 Views
4 Replies
Message 1 of 5

bad argument type: VLA-OBJECT NIL...exasperated trying to fix

Anonymous
Not applicable

I've been trying to build several LISPS for coloring items in blocks.  This latest error has me completely stumped, I had it working earlier today, and of course now I've lost it.

 

I'm getting an error "bad argument type: VLA-OBJECT NIL."  I've searched for a while and it seems like an avalanche of issues can cause this.  I've loaded the code into the Visual LISP editor inside ACAD, and gotten all the parentheses are straightened out, so at least the code loads initially ok.  I've tried tracing the error, but I can't get anywhere with the :CALLBACK-ENTRY error message.  AAAAGH!!

 

The part that isn't cooperating is where I am trying to send ellipses to a certain layer.  I swear I've checked all the formatting, used code from previously higher up in the LISP, but I just can't get the darn thing to cooperate; files are attached. Thanks for any help!

0 Likes
1,683 Views
4 Replies
Replies (4)
Message 2 of 5

Shneuph
Collaborator
Collaborator

See attached.  Hope it works.

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks for the contribution, but still no dice, same error.

0 Likes
Message 4 of 5

Anonymous
Not applicable

I guess it must be some formatting error, I just stripped the whole routine down to JUST the ellipse code, and of course, NOW it works. That's 3 hours I'd like to get back...live and learn Smiley Sad

0 Likes
Message 5 of 5

joselggalan
Advocate
Advocate

I can not examine all code by missing data in dwg, but this works.
I hope this right.

Regards.

 

 

ange color and/or layer of objects inside blocks
;Author Stefan M.                                  
;version 2.03 - 20.05.2016
(vl-load-com)
(defun c:curveblk ( / a acdoc anglee blocks arr def e frm i l la lg p1 p2 rol sanglee sns ss)
  (setq acdoc (vla-get-activedocument (vlax-get-acad-object))
        blocks (vla-get-blocks acdoc))
  (foreach x '(("HILMOT FRAMES" 4) ("HILMOT MDR" 3) ("HILMOT ROLLER" 8) ("HILMOT SENSOR" 1))
     (or
       (tblsearch "layer" (car x))
       (entmake
         (list
           '(0 . "LAYER")
           '(100 . "AcDbSymbolTableRecord")
           '(100 . "AcDbLayerTableRecord")
           (cons 2 (car x))
           '(70 . 0)
           (cons 62 (cadr x))
           '(6 . "Continuous")
         )
       )
     )
   )
  (cond
   ((setq ss (ssget ":L" '((0 . "INSERT"))))
      (repeat (setq i (sslength ss))
        (setq e (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
        (if
          (not (member (setq def (vla-item blocks (vlax-get e (if (vlax-property-available-p e 'EffectiveName) 'EffectiveName 'Name)))) l))
          (setq l (cons def l))
        )
      )
      (foreach b l
       (setq frm nil
	     sns nil
	     rol nil
	     mdr nil
       )
       (vlax-for obj b
	(cond
	 ((equal (vla-get-objectname obj) "AcDbLine")
	  (setq anglee (vla-get-angle obj))
	  (vla-put-color obj 256)
	  (cond
	   ((equal anglee 0.2705047 1e-6)
	    (setq mdr (cons obj mdr))
	   )
	   ((equal anglee 0.34036 1e-5)
	    (setq mdr (cons obj mdr))
	   )
	   ((equal anglee 1.0559 1e-4)
	    (setq mdr (cons obj mdr))
	   )
	   ((equal anglee 1.125758 1e-6)
	    (setq mdr (cons obj mdr))
	   )
	   ((equal anglee 0.087266 1e-6)
	    (setq SNS (cons obj sns))
	   )
	   ((equal anglee 0.872665 1e-6)
	    (setq SNS (cons obj sns))
	   )
	   (t (setq rol (cons obj rol)))
	  )
	)
	((equal (vla-get-objectname obj) "AcDbSpline")
	  (vla-put-color obj 256)
	  (setq frm (cons obj frm))
	)
	 ((equal (vla-get-objectname obj) "AcDbEllipse")
	  (setq sanglee (vla-get-StartAngle obj))
	  (vla-put-color obj 256)
	  (cond
	   ((equal sanglee 0) (setq mdr (cons obj mdr)))
	   (T (setq rol (cons obj rol)))
	  )
	 )
       );c.cond
      )
      (mapcar
       '(lambda (o la)
	 (mapcar '(lambda (a) (vla-put-layer a la)) o)
	)
       (list frm rol sns mdr)
       '("HILMOT FRAMES" "HILMOT ROLLER" "HILMOT SENSOR" "HILMOT MDR")
      )
     )
     (vla-Regen acdoc acAllViewports)
   )
 )
(command "regen")
(princ)

)