Author Topic: VL layer object properties and DXF codes  (Read 1692 times)

0 Members and 1 Guest are viewing this topic.

Paul Munford

  • Guest
VL layer object properties and DXF codes
« on: February 06, 2009, 12:21:28 PM »
with thanks to all at this thread:

http://www.theswamp.org/index.php?topic=10992.0

I've managed to hack together these two snippets. They work but they're not pretty!

It seems clunky to be converting Objects into entities and back again. I would be interested to know if you can come up with anything a bit more slick...

Code: [Select]
;;Put all the viewports on the standard layer, including clipped viewports and their clipping boundarys.

(foreach n Vportlist
(vlax-put-property n 'layer "VPORTS")
(if
(eq (vlax-get-property n 'clipped):vlax-true)  
(progn
(setq ClipObject (assoc 340 (entget (vlax-vla-object->ename n))))
(vlax-put-property (vlax-Ename->Vla-Object (cdr ClipObject))'layer "VPORTS")
); end progn
);end if
);end foreach

;;Delete all the 'Ex' viewport layers, if they are not still in use.

(foreach n VPLayers
(if
(and
(/= "VPORTS" n)
(/= 64 (cdr (assoc 70 (entget (vlax-vla-object->ename(vla-item acadLayers n))))))
);end and
(vla-delete(vla-item acadLayers n))
);end if
);end foreach


ronjonp

  • Needs a day job
  • Posts: 7526
Re: VL layer object properties and DXF codes
« Reply #1 on: February 06, 2009, 01:12:00 PM »
This is how I'd do it....I don't think you need to check for clipped.

;;Put all the viewports on the standard layer, including clipped viewports and their clipping boundarys.

Code: [Select]
(foreach n vportlist
  (vla-put-layer n "VPORTS")
  (if (setq clipobject (assoc 340 (entget (vlax-vla-object->ename n))))
    (vlax-put-property (vlax-ename->vla-object (cdr clipobject))
                       'layer
                       "VPORTS"
    )
  ) ; end progn
) ;end foreach

;;purge unused layers
(repeat 2
  (vla-purgeall
    (vla-get-activedocument (vlax-get-acad-object))
  )
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: VL layer object properties and DXF codes
« Reply #2 on: February 06, 2009, 01:17:02 PM »
Untested 8-)
Code: [Select]
;;Put all the viewports on the standard layer, including clipped viewports and their clipping boundarys.
(foreach obj Vportlist
  (vlax-put-property obj 'layer "VPORTS")
  (if (setq ent (assoc 340 (entget (vlax-vla-object->ename obj))))
    (vla-put-layer (vlax-ename->vla-object (cdr ent)) "VPORTS")
  )
)         ;end foreach

;;Delete all the 'Ex' viewport layers, if they are not still in use.

(foreach n VPLayers
  (vl-catch-all-apply 'vla-delete (list (vla-item acadLayers n)))
)
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.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: VL layer object properties and DXF codes
« Reply #3 on: February 06, 2009, 01:24:05 PM »
And my addition to CAB's remove layer code (not sure if it really helps though) :-D

Code: [Select]
(foreach n (vl-remove-if '(lambda (x) (wcmatch (vla-get-name x) "*|*"));;take out xref layers
                         vplayers
           )
  (vl-catch-all-apply 'vla-delete
                      (list (vla-item acadlayers n))
  )
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Paul Munford

  • Guest
Re: VL layer object properties and DXF codes
« Reply #4 on: February 06, 2009, 03:54:48 PM »
I love this place!

Thanks for your replies, definitely food for thought :-)