TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: viva on September 28, 2006, 08:47:05 AM

Title: vla-functions
Post by: viva on September 28, 2006, 08:47:05 AM
hi everybody,
             i had copied the polyline features by using
   
Code: [Select]
(setq sel(ssget "x" (list(cons 0 "lwpolyline")(cons 8 "layer1"))))
     (if sel
(progn
     (setq cnt 0)
     (repeat (- (length sel) 1)
     (setq ent(ssname sel cnt))
      (setq obj(vlax-ename->vla-object ent)
     
Code: [Select]
(setq cop(vla-copy obj)then i want 2 create a new layer and put the copied features in that layer thru vla functions.

i had used

vla-add
but it is showing  " activex error"

can anyone help regarding this things

thanks in advance


regards
vivek
<edit: corrected code tags>
Title: Re: vla-functions
Post by: CAB on September 28, 2006, 09:05:49 AM
Look into this:
     
Code: [Select]
(vla-put-layer newpline (vla-get-layer obj))
Title: Re: vla-functions
Post by: viva on September 28, 2006, 09:22:35 AM
hi cab,
           thanks for ur immediate reply. (vla-get-layer obj) .can u tell me here obj means. obj means layername or objectname. plz explain me. that will help me alot. i cant able 2 find out vla functions in help.
 i got error while using
(vla-put-layer newpline (vla-get-layer obj))

; error: bad argument type: VLA-OBJECT nil

thanks

regards
vivek
Title: Re: vla-functions
Post by: CAB on September 28, 2006, 09:56:46 AM
it is the object layer property name <correction>
Code: [Select]
(setq obj (vlax-ename->vla-object (car(entsel))))
Title: Re: vla-functions
Post by: T.Willey on September 28, 2006, 11:17:37 AM
You use (vla-add ... ) when you want to create something new somewhere.  In your case, you would use it if the layer doesn't exist in the drawing.  To get the active drawing (document) use
Code: [Select]
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))Then if you want to add a layer, you have to get the layer collection (table) first, like so
Code: [Select]
(setq LayCol (vla-get-Layers ActDoc))Now if you want to add the new layer, now you use add like so
Code: [Select]
(vla-Add LayCol "MyNewLayerName")
Now if you want to put the objects returned by (vla-copy ... ), I would use 'copy' like you have it, and then you just need to update the layer of the new object you created, so add this portion to your code after you copy.
Code: [Select]
(vla-put-Layer cop "MyNewLayerName")
Hope that makes sense.
Title: Re: vla-functions
Post by: CAB on September 28, 2006, 11:48:23 AM
Thanks Tim for the clarification & correction.
I guess I shot through here too fast this morning. :-)
Title: Re: vla-functions
Post by: T.Willey on September 28, 2006, 11:55:36 AM
Thanks Tim for the clarification & correction.
I guess I shot through here too fast this morning. :-)
No problem Alan.  I help where I can.  :-)
Title: Re: vla-functions
Post by: Krushert on September 28, 2006, 12:55:32 PM
Thanks to both of you for clarifying and explaining how things work. 

I will go back to watch and learning now.
 :-)
Title: Re: vla-functions
Post by: viva on September 29, 2006, 12:36:50 AM
hi
    thanks for both. i had learned new things from ur discussion. it helped alot

regards
vivek
Title: Re: vla-functions
Post by: JohnK on October 09, 2006, 09:44:40 PM
The ``vla'' prefix is used for accessing methods and properties of ActiveX objects.
The ``vlax'' prefix is a general prefix used for other ActiveX objects. (like word, excel, …Other applications in general.) You use this prefix to get/put properties of other ActiveX objects.