Linetype Lisp Routine - Modify to revert to previous settings

Discussion in 'AutoCAD' started by hpcapers, Jul 28, 2004.

  1. hpcapers

    hpcapers Guest

    I have a lisp that creates a layer, sets color, loads linetype, sets to that current layer and allows you to properly draw a new linetype. What is the best way to incorporate a reversion back to the previous settings. Would I need to take an entire 'snapshot' of all settings? Thanks

    Please only respond with your message - repeating the previous posts just makes the thread unable to be read. Thanks

    My sample is below:

    [Temp Work Space (TWS)]^C^C(Command ".layer" "m" "Easmnt_tws_gis" "c" 230 "" "lt" "hidden2" "" "") _plinewid 0 _pline;
     
    hpcapers, Jul 28, 2004
    #1
  2. I assume your reversion back to the previous settings would mean going back
    to whatever Layer was current when you invoked this, which would also get
    you back to its color and linetype, since your sample is making those
    settings part of the new layer, not overriding them with something other
    than "bylayer" for all new entities. If that's what you need, just save the
    current layer first:

    (setq currlayer (getvar "clayer"))

    Then at the end, set it back:

    -LAYER S !currlayer ;
    or
    (command "layer" "s" currlayer "")

    The tricky part is allowing yourself to draw your polyline at any number of
    segments. You need it to check whether you've ended the Pline command yet:

    (while (> (getvar "cmdactive") 0))

    will return T if there's a command active. Once it doesn't, you can invoke
    the layer resetting.

    Kent Cooper, AIA


    that current layer and allows you to properly draw a new linetype. What is
    the best way to incorporate a reversion back to the previous settings.
    Would I need to take an entire 'snapshot' of all settings? Thanks
    "" "lt" "hidden2" "" "") _plinewid 0 _pline;
     
    Kent Cooper, AIA, Jul 28, 2004
    #2
  3. hpcapers

    hpcapers Guest

    Hey Kent - thanks..

    I tried to implement, but am unsure of the sequence. By your suggestion, I felt I would initially only be able to draw one segment when I implemented the return layer setting, however, I was unable to get the layer save/return to initiate. Will attempt again when I get a moment.

    [Road CL **]^C^C(setq currlayer (getvar "clayer"))(Command ".layer" "m" "ROAD_CL" "c" 144 "" "lt" "Center2" "" "") _plinewid 0 _pline; (command "layer" "s" currlayer "")
     
    hpcapers, Jul 28, 2004
    #3
  4. If one segment is enough, you don't need the (while) business. Just give it
    two \'s for user input of the two endpoints. This should work:

    [Road CL **]^C^C(setq currlayer (getvar "clayer")) +
    (Command ".layer" "m" "ROAD_CL" "c" 144 "" "lt" "Center2" "" "") +
    _plinewid 0 _pline \\; (command "layer" "s" currlayer "")

    The way you have it (below) calls up the pline command, but resets the layer
    before the user has a chance to draw the pline.

    [If it's only one segment, a plain old Line ought to do, unless you need
    width or something.]

    Kent Cooper, AIA


    I felt I would initially only be able to draw one segment when I implemented
    the return layer setting, however, I was unable to get the layer save/return
    to initiate. Will attempt again when I get a moment.
    "ROAD_CL" "c" 144 "" "lt" "Center2" "" "") _plinewid 0 _pline; (command
    "layer" "s" currlayer "")
     
    Kent Cooper, AIA, Jul 28, 2004
    #4
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.