Author Topic: Layer filter delete with filter  (Read 7996 times)

0 Members and 1 Guest are viewing this topic.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Layer filter delete with filter
« Reply #15 on: March 01, 2006, 06:58:33 PM »
Off topic, but ... if you invoke the vla-GetExtensionDictionary method on an entity / object that does not have an extension dictionary said method will add one -- undesirable behavior in most situations. In these situtations it is better to test and conditionally retrieve the extension dictionary --

i.e.

Code: [Select]
(if (eq :vlax-true (vla-get-HasExtensionDictionary object))
    (progn
        (setq xdict (vla-GetExtensionDictionary object))
        ...
    )
)

We now return you to your regularly scheduled discussion ...

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Layer filter delete with filter
« Reply #16 on: March 01, 2006, 07:06:30 PM »
and not trying to tag team you ..

Using something like this is a little safer than just using (vla-item obj index)

Code: [Select]
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
(defun k:AssertItem (collection item / returnvalue)
  (if
    (not (vl-catch-all-error-p
           (setq returnvalue (vl-catch-all-apply 'vla-item (list collection item)))
         )
    )
     returnvalue
  )
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Layer filter delete with filter
« Reply #17 on: March 01, 2006, 07:31:29 PM »
Thank guys...my brain hurts now.  :-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Layer filter delete with filter
« Reply #18 on: March 01, 2006, 07:45:17 PM »
Relatively simple < the routine, not "Hurting your head" ;) >

Just replace the call to vla-item with k:AssertItem using the same parameters.
The routine will return either the Object related to 'item' or NIL.

.. bypassing the possible dummy-spit in the instance where the 'item' translation errors out.


added:
This could , of course, be written in line each time ... but I type slowly, so ...
 
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.