Layer Properties - ActiveX vss Command

Discussion in 'AutoCAD' started by David Kozina, Jul 13, 2004.

  1. David Kozina

    David Kozina Guest

    I am curious if it would be feasable/advantageous to control the properties
    of multiple layers (via a layer name wildcard pattern) via ActiveX functions
    as opposed to the
    (command "_.-LAYER" ... function.

    Example:
    Given LayerName_str = "S-WALL-*-PATT*"

    I could turn on the layers matching this filter pattern simply via:

    (command
    "_.-LAYER"
    "_On"
    LayerName_str
    ""
    )

    But I was wondering if there might be a relatively simple way to do this
    type of layer name filter pattern matching with a collection of ActiveX
    Layer objects?
    Once I had this I could simply do:

    (vlax-for Layer_obj Layer_coll
    (vlax-put-property
    Layer_obj
    'LayerOn
    :vlax-true
    )
    )

    I am asking this since I would assume there might be advantages in speed and
    efficiency (though perhaps not noticeable to the end user).

    If there ARE some real advantages to doing this, what is the best way to
    CREATE (and/or process) the collection using a layer name filter? (Or am I
    even going about this process the wrong way?)

    Best regards,
    David Kozina
     
    David Kozina, Jul 13, 2004
    #1
  2. David,

    Not sure about speed - but one advantage of activex over commands is that you can call them from open dcl dialogs.

    As for filtering - get the layer name and use wcmatch.

    Peter
     
    petersciganek, Jul 13, 2004
    #2
  3. David Kozina

    David Kozina Guest

    Peter,

    I appreciate the info regarding dcl issues (although it's not a problem in
    this case).

    I realize that I can look up the name and wcmatch it with the name filter
    pattern - I guess I was mainly wondering if anyone knew (or had evidence)
    that doing all this (repetitive wcmatching) was more (or less) feasable than
    just using command with a name pattern string. OR if there was an even
    better way (that I'm completely overlooking.)

    I'm of the understanding that (command... is slow and to be avoided when
    feasible - but how about in comparison to doing wcmatch tests a hundred or a
    thousand times or more? (Is there a way to test a pattern across an entire
    collection of objects in one shot?)

    Does this make any sense to anyone?

    Best regards,
    David Kozina


    you can call them from open dcl dialogs.
     
    David Kozina, Jul 13, 2004
    #3
  4. David Kozina

    dstein Guest

    Another consideration is if you use command reactors you should try to use ActiveX methods instead of (command) or (vl-cmdf) calls to avoid interference.
     
    dstein, Jul 14, 2004
    #4
  5. David Kozina

    Doug Broad Guest

    From my limited tests, it looks like ActiveX is about 30 times faster
    than command methods.
     
    Doug Broad, Jul 14, 2004
    #5
  6. David Kozina

    David Kozina Guest

    Doug,

    Would it still be faster even when considering the dozens upon dozens
    (perhaps hundreds) of times I'll need to use a (wcmatch... pattern test on
    the layer names? This is *before* the ActiveX functions get to be
    applied...

    I don't doubt that the ActiveX functions are much faster, but it's the stuff
    I've got to deal with ahead of time that I'm wondering about...

    Or are you saying that execution times [et] would *still* relate as follows:
    et(command...) = ( et(wcmatch...)*100*n + et(ActiveX function) ) * 30)

    Does my question make any sense?

    I've noticed that most 'layer questions' answered in this newsgroup end up
    going the (command... route, perhaps for simplicity and ease of use. David
    Stein brought up another salient point regarding reactor/command conflicts
    (but I don't need to deal with that particular issue at the moment, either).

    I'm just trying to evaluate if I should take the time to rethink my layer
    control processes, or just stay with the evil yet simplistic (command...

    Best regards,
    David Kozina
     
    David Kozina, Jul 14, 2004
    #6
  7. David Kozina

    Doug Broad Guest

    David,
    This is probably oversimplified test but why don't you
    try it out on a few of your drawings and post your conclusions
    or critique this code for its weaknesses. I didn't attempt to
    optimize anything.

    ;;Layer toggle test programs by
    ;;D. C. Broad 7/13/2004
    ;;;command only method - turns all layers off and then
    ;;;back on
    (defun C:LAY1 ()
    (command "-layer" "off" "*" "n" "")
    (command "-layer" "on" "*" ""))


    ;;activeX method - turns all layers off and then on
    (defun C:LAY2 (/ LAYS LAY)
    (vlax-for LAY (vla-get-layers
    (vla-get-activedocument
    (vlax-get-acad-object)))
    ;;following if statement is only included to test
    ;;performance of string matching. Not really necessary
    ;;if *all* layers were to be turned off.
    (if (wcmatch (vla-get-name lay) "*")
    (vla-put-layeron LAY :vlax-false)))
    (vlax-for LAY (vla-get-layers
    (vla-get-activedocument
    (vlax-get-acad-object)))
    (if (wcmatch (vla-get-name lay) "*")
    (vla-put-layeron LAY :vlax-true))))


    (load "bench") ;;By R. Robert Bell (download separately)

    (bench '(c:lay1 c:lay2) nil 1000) ;;How to run the timing program

     
    Doug Broad, Jul 14, 2004
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.