Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
scotts
594 Views, 7 Replies

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

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

 

7 REPLIES 7
Message 2 of 8
pbejse
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*"))

Message 3 of 8
scotts
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.

Message 4 of 8
pbejse
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

 

 

Message 5 of 8
scotts
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 

Message 6 of 8
pbejse
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)

 

 

Message 7 of 8
scotts
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!Smiley LOL

Message 8 of 8
pbejse
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!Smiley LOL



Good for you, Glad i could help

 

Cheers

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost