Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Active Contributor
scotts
Posts: 30
Registered: ‎07-25-2008
Message 1 of 8 (287 Views)
Accepted Solution

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

287 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

 


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)

 

 

*Expert Elite*
pbejse
Posts: 2,482
Registered: ‎11-24-2009
Message 2 of 8 (285 Views)

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*"))

Active Contributor
scotts
Posts: 30
Registered: ‎07-25-2008
Message 3 of 8 (280 Views)

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.

*Expert Elite*
pbejse
Posts: 2,482
Registered: ‎11-24-2009
Message 4 of 8 (276 Views)

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

 

 

Active Contributor
scotts
Posts: 30
Registered: ‎07-25-2008
Message 5 of 8 (274 Views)

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 

*Expert Elite*
pbejse
Posts: 2,482
Registered: ‎11-24-2009
Message 6 of 8 (267 Views)

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)

 

 

Active Contributor
scotts
Posts: 30
Registered: ‎07-25-2008
Message 7 of 8 (265 Views)

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:

*Expert Elite*
pbejse
Posts: 2,482
Registered: ‎11-24-2009
Message 8 of 8 (258 Views)

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

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.