Jump to content

bad argument type: VLA-OBJECT nil, why?


Grrr

Recommended Posts

Hello everyone!

I don't understand why I'm getting this error, when I'm trying to incorporate the IF function.

Command: TEST
Error: bad argument type: VLA-OBJECT nil

 

;;
;;D:\Program Files\Autodesk\AutoCAD 2015\Fonts - path for ACAD .shx files
;;D:\Fonts\ - My path
;;C:\Windows\Fonts - path for windows .ttf files

;; Optional: Make the new style Active 
;;(vla-put-activetextstyle acadDoc objStyle)


(defun c:test ()
(vl-load-com) 
(setq acadApp (vlax-get-Acad-object)) 
(setq acadDoc (vla-get-ActiveDocument acadApp)) 
(setq styles (vla-get-textstyles acadDoc))

;; Add the style named:
   (setq st-name "VLD_simplex")
   (if (not (tblsearch "STYLE" st-name)) 
   (
   (setq objStyle (vla-add styles st-name))
;; Assign fontfile to the style:
   (setq ff "D:\\Program Files\\Autodesk\\AutoCAD 2015\\Fonts\\simplex8.shx") ;fontfile path here 
   (vla-put-fontfile objStyle ff)
   );then
   (princ (strcat "\n " st-name " style already defined!" ));else
   );if

(princ)
)

Link to comment
Share on other sites

You may need a progn in the if

my version

(if (= (tblsearch "STYLE" st-name) nil) 
   (progn  
   (setq objStyle (vla-add styles st-name))
;; Assign fontfile to the style:
   (setq ff "D:\\Program Files\\Autodesk\\AutoCAD 2015\\Fonts\\simplex8.shx") ;fontfile path here 
   (vla-put-fontfile objStyle ff)
   ); progn
   (princ (strcat "\n " st-name " style already defined!" ));else
   );if

Link to comment
Share on other sites

Thank you, BIGAL!

I solved it myself little bit earlier - still learning new functions, in my first time error handling experience.

Also I'm trying to transition more into VLA (its a pain in the a**).

 

Happy New Year! :)

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