Author Topic: vla-functions  (Read 3140 times)

0 Members and 1 Guest are viewing this topic.

viva

  • Guest
vla-functions
« 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>
« Last Edit: September 28, 2006, 08:56:43 AM by CAB »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: vla-functions
« Reply #1 on: September 28, 2006, 09:05:49 AM »
Look into this:
     
Code: [Select]
(vla-put-layer newpline (vla-get-layer obj))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

viva

  • Guest
Re: vla-functions
« Reply #2 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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: vla-functions
« Reply #3 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))))
« Last Edit: September 28, 2006, 11:45:30 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: vla-functions
« Reply #4 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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: vla-functions
« Reply #5 on: September 28, 2006, 11:48:23 AM »
Thanks Tim for the clarification & correction.
I guess I shot through here too fast this morning. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: vla-functions
« Reply #6 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.  :-)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: vla-functions
« Reply #7 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.
 :-)
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

viva

  • Guest
Re: vla-functions
« Reply #8 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

JohnK

  • Administrator
  • Seagull
  • Posts: 10604
Re: vla-functions
« Reply #9 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.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org