Jump to content

VLA Create Block Definition and Add Entity...


eimimitu

Recommended Posts

I seem to be stuck..

Combed through all the documentation plus google searches...

 

What am I missing?

Can't seem to add object to my block definition...

 

vl-load-com loaded

ActiveDocument loaded...

Acad-Object loaded...

 

(setq fax (vlax-ename->vla-object far)) ;returns #<VLA-OBJECT IAcadSolid 0000024d51846d98>
(setq blk (vla-get-Blocks doc)) ;returns #<VLA-OBJECT IAcadBlocks 0000024d3ecb3a38>
(setq fab (vla-Add blk fpa "_ClosedFilled")) ;returns #<VLA-OBJECT IAcadBlock 0000024d37310cf8>
(setq fax (vla-CopyObjects doc fax fab)) ;returns nothing!!!!????

 

Your thoughts?............

Link to comment
Share on other sites

I followed your link BIGAL... all the way to Lee Mac's "AddObjectstoBlock" lisp.... I see similar syntax in his routine:

 

(vla-CopyObjects (ActiveDoc variable) (list of objects to add) (block reference name))

 

I still don't get why mine won't work... I'm thinking maybe I have either the entity variable or the block reference variable in an improper form... maybe i cannot add the single entity i get from "vlax-ename->vla-object x"... maybe it expects an selection set array... maybe it expects some other info before it can add the object.... i don't know...:?

Link to comment
Share on other sites

Hi,

 

To avoid the safearray just use the vlax-invoke instead besides that you need to have your vla-object(s) as a list.

 

(vlax-invoke doc 'CopyObjects (list fax) fab)

Link to comment
Share on other sites

oooh! wow... I spent the whole day spinning my wheels.. Thanks Tharwat... I'll try it out and report back....

 

funny thing is I tried this method as well but without list.. same nil..:oops:

 

So just to be clear though... the first method does require a safearray of objects? Also can a safearray contain a single object? just for future reference...:thumbsup:

 

Thank you both!

Link to comment
Share on other sites

oooh! wow... I spent the whole day spinning my wheels.. Thanks Tharwat... I'll try it out and report back....

 

funny thing is I tried this method as well but without list.. same nil..:oops:

 

So just to be clear though... the first method does require a safearray of objects? Also can a safearray contain a single object? just for future reference...:thumbsup:

You are welcome. :)

 

Certainly, have a look at the following for your reference that contains a single object ( and not married one. :lol: ).

(setq safe (vlax-make-safearray vlax-vbObject '(0 . 0)))
(vlax-safearray-put-element safe 0 fax)

(vla-CopyObjects doc safe fab)

Link to comment
Share on other sites

I always forget that the methods sometimes require safearrays...

Makes me think does a variant type of argument is required anywhere? So one would be forced to use vlax-make-variant function.

Link to comment
Share on other sites

this is what I ended up with after reviewing some of the links provided:

 

(setq sav (vlax-ename->vla-object sar))
(vla-Rotate sav (setq spa (vlax-3d-point spo)) (- (dtr 180.0) (angle spo tpo)))
(vlax-invoke doc 'CopyObjects (list sav) (vla-Add (vla-get-Blocks doc) spa "_ClosedFilled"))
(vla-delete sav)
(setq sax (vla-InsertBlock (if (= (getvar 'tilemode) 1) (vla-get-ModelSpace doc) (vla-get-PaperSpace doc)) spa "_ClosedFilled" 1.0 1.0 1.0 0.0))

 

Thanks everyone for your input....

 

That change block name with DCL preview is pretty sweet

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