Closing with

Discussion in 'AutoCAD' started by T.Willey, Jul 12, 2004.

  1. T.Willey

    T.Willey Guest

    I am trying to close drawing that I select with a dialog box. I have the code and it seems to work, but it always saves them. This is the part of the code that I can't seem to get to work.

    Code:
    (vlax-for item tx5
    (if (= tx8 (vla-get-name item))
    (if (= tx9 "1")
    (vla-close item :vla-true)
    (vla-close item :vla-false)
    )
    )
    )
    
    I looked in the help and it seems that it wants to save the drawing no matter what if you try and close it from a document collection.

    <snip>

    Variant; input-only; optional
    (Not applicable when called from Documents collection.)
    Specifies if the drawing is to be saved or not.

    TRUE: Save the drawing.

    FALSE: Do not save the drawing.

    <snip>

    Any help is greatly appreciated.

    Tim
     
    T.Willey, Jul 12, 2004
    #1
  2. T.Willey

    T.Willey Guest

    This is as far as I have been able to get this, first is the dcl then the lisp that goes along with it. Any help is appreciated.

    Cdrawings : dialog{
    label = "Select Drawings to Close";
    : row {
    : list_box {
    label = "layers";
    key = "tx2";
    edit_width = 60;
    allow_accept = true;
    multiple_select = true;
    }
    }
    : toggle {
    label = "Save drawing when closed?";
    key = "d-save";
    }

    : row {
    : spacer { width = 1; }

    : button { // defines the OK button
    label = "OK";
    is_default = true;
    allow_accept = true;
    key = "accept";
    width = 8;
    fixed_width = true;
    }

    : button { // defines the Cancel button
    label = "Cancel";
    is_cancel = true;
    key = "cancel";
    width = 8;
    fixed_width = true;
    }

    : spacer { width = 1;}
    }

    }

    ////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////

    (defun c:test1(/ tx1 tx2 tx3 tx4 tx5 tx6 tx7 tx8 tx9 op1 tlng1 tlng2)

    (setq tx3 nil)
    (Setq tx4 nil)
    (setq tx5 (vla-get-documents (vlax-get-acad-object)))
    (vlax-for item tx5
    (setq tx3 (list (vla-get-name item))); update the list
    (setq tx4 (append tx4 tx3))
    )

    (setq op1 (load_dialog "CloseDwg.dcl"))
    (if (not (new_dialog "Cdrawings" op1))
    (exit)
    )
    (start_list "tx2" 3); clear the list
    (mapcar 'add_list tx4)
    (end_list)

    (action_tile "accept"
    "(progn
    (setq tx2 (get_tile \"tx2\"))
    (setq tx9 (get_tile \"d-save\"))
    (done_dialog 1)
    )"
    )
    (action_tile "cancel"
    "(progn
    (setq tx2 nil)
    (setq tx9 (get_tile \"d-save\"))
    (done_dialog 1)
    )"
    )
    (start_dialog)
    (if tx2
    (Closing)
    (setq tlng2 "0")
    )
    (prompt (strcat "\n "tlng2" drawing(s) have been close."))
    (princ)

    )

    (defun Closing()

    (setq tx7 (mapcar 'chr (vl-string->list tx2)))
    (setq tlng1 (/ (vl-list-length tx7) 2.0))
    (if (/= (rem tlng1 1) 0)
    (setq tlng1 (+ 0.5 tlng1))
    )
    (setq tlng2 (itoa (fix tlng1)))

    (repeat (fix tlng1)
    (setq tx6 (atoi (car tx7)))
    (setq tx8 (nth tx6 tx4))
    (vlax-for item tx5
    (if (= tx8 (vla-get-name item))
    (if (= tx9 "1")
    (vla-close item :vla-true)
    (vla-close item :vla-false)
    )
    )
    )
    (setq tx7 (cdr tx7))
    (if tx7
    (if (= (atoi (car tx7)) 0)
    (setq tx7 (cdr tx7))
    )
    )
    )

    )

    It still only saves the drawings when closing them even when I use ":vla-false" to tell it not to.

    Tim
     
    T.Willey, Jul 13, 2004
    #2
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.