Jump to content
eimimitu

VLA Create Block Definition and Add Entity...

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

Share this post


Link to post
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...:?

Share this post


Link to post
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)

Share this post


Link to post
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!

Share this post


Link to post
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)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

good (- 3 2) Tharwat:lol: Some objects just aren't ready to settle down... :P

 

It worked... freakin' brillant! TY!

Share this post


Link to post
Share on other sites
good (- 3 2) Tharwat:lol: Some objects just aren't ready to settle down... :P

 

It worked... freakin' brillant! TY!

 

:D You are welcome anytime.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×