• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual LISP, AutoLISP and General Customization

    Reply
    Active Contributor
    Posts: 30
    Registered: ‎07-25-2008
    Accepted Solution

    Do this if the drawing name is not equal to this...

    157 Views, 7 Replies
    03-29-2012 07:44 AM

    So I want to write a quick little log when I open drawings and I want it to run automatically but only if the drawing name is not equal to "drawing..." since Civil 3D always starts with drawing1 and any new drawings are named drawing2, drawing3, etc.  It seems to always evaluate yes even in drawings named "Drawing1".  What am I doing wrong?

     

    (vl-load-com)
    
    (defun toDate (var format)
      (menucmd (strcat "m=$(edtime,$(getvar," var ")," format ")"))
    );defun
    
    
    (defun C:CSW-Make_User_Log_On_Open ()
      (if (/= (getvar "dwgname") "Drawing*")
        (progn 
           (setq log (open (strcat "U:/IND-CAD-DIR/Z-User_Log/" (getvar "loginname") "-log.csv") "a"))
           (write-line (strcat "DRAWING OPENED:," (getvar "dwgprefix") (getvar 'DWGNAME) "," "DATE:," (toDate "DATE" "MO-DD-YYYY HH") ":" (toDate "DATE" "MM") "," "EDIT TIME:," (rtos (acet-edittime-total) 2 8) "\n") log)
           (close log)
        );progn
      );if
      (princ)
    );defun

     

    Please use plain text.
    *Expert Elite*
    Posts: 2,066
    Registered: ‎11-24-2009

    Re: Do this if the drawing name is not equal to this...

    03-29-2012 07:55 AM in reply to: scotts

    scotts wrote:

    So I want to write a quick little log when I open drawings and I want it to run automatically but only if the drawing name is not equal to "drawing..." since Civil 3D always starts with drawing1 and any new drawings are named drawing2, drawing3, etc.  It seems to always evaluate yes even in drawings named "Drawing1".  What am I doing wrong?

     

     



    look into (getvar 'DWGTITLED)

     

     As for your code

    (not (wcmatch  (getvar "dwgname") "Drawing*"))

    Please use plain text.
    Active Contributor
    Posts: 30
    Registered: ‎07-25-2008

    Re: Do this if the drawing name is not equal to this...

    03-29-2012 08:03 AM in reply to: pbejse

    Thanks I can get it to evaluate correctly, but it still doesn't run the code if it evaluates to true.  I'm guessing I'm not using the progn function properly.

    Please use plain text.
    *Expert Elite*
    Posts: 2,066
    Registered: ‎11-24-2009

    Re: Do this if the drawing name is not equal to this...

    03-29-2012 08:17 AM in reply to: scotts

    scotts wrote:

    Thanks I can get it to evaluate correctly, but it still doesn't run the code if it evaluates to true.  I'm guessing I'm not using the progn function properly.



    You can do it. what will be the resullt for (rtos (acet-edittime-total) 2 8)? that doesnt to work for me here

     

    Edit: (acet-edittime-enable 1) need this to work on my cad

     

    it appears to be working here scotts

     

     

    Please use plain text.
    Active Contributor
    Posts: 30
    Registered: ‎07-25-2008

    Re: Do this if the drawing name is not equal to this...

    03-29-2012 08:22 AM in reply to: pbejse

    I think it will nil out if your drawing doesn't have edittime set to on and the drawing hasn't been saved (with edittime on). 

     

    -Scott 

    Please use plain text.
    *Expert Elite*
    Posts: 2,066
    Registered: ‎11-24-2009

    Re: Do this if the drawing name is not equal to this...

    03-29-2012 08:30 AM in reply to: scotts

    scotts wrote:

    I think it will nil out if your drawing doesn't have edittime set to on and the drawing hasn't been saved (with edittime on). 

     

    -Scott 



    Yup. i would suggest you use

    (if (= (getvar 'DWGTITLED) 1) ;1 means the drawing have been saved

    (do this)

     

     

    Please use plain text.
    Active Contributor
    Posts: 30
    Registered: ‎07-25-2008

    Re: Do this if the drawing name is not equal to this...

    03-29-2012 08:32 AM in reply to: pbejse

    Got it to work.  I was using "1" instead of just 1 for the evaluation.  Got to watch my syntax.  Thanks for your help, now to create a reactor that will run it when i close a drawing!:smileylol:

    Please use plain text.
    *Expert Elite*
    Posts: 2,066
    Registered: ‎11-24-2009

    Re: Do this if the drawing name is not equal to this...

    03-29-2012 08:55 AM in reply to: scotts

    scotts wrote:

    Got it to work.  I was using "1" instead of just 1 for the evaluation.  Got to watch my syntax.  Thanks for your help, now to create a reactor that will run it when i close a drawing!:smileylol:



    Good for you, Glad i could help

     

    Cheers

    Please use plain text.