Jump to content

Recommended Posts

Posted

Hello have the contribution from there but I think he is better off here.
https://www.cadtutor.net/forum/topic/65849-action-planner-for-productivity/

Can someone help me please?

Hello,
Please help
I want to open the file in WordPad. This works fine if there is no "." In the DWG name. or "space" is included. But I can not change the name. How can the Lisp
accept the point to make it work?
Thank you
Martin

 

Example file name:
This name does not work "179062-0000018159-Fa. Martin.dwg"
This name works "179062-0000018159-FaMartin.dwg"

 

 

(defun c:todo ( / dwgname dwgpre todofname )
  (setq dwgname (GETVAR "dwgname"))
  (setq dwgname (substr dwgname 1 (- (strlen dwgname) 4)))
  (setq dwgpre (getvar "dwgprefix"))
  (setq todofname (strcat dwgpre dwgname ".Txt" ))
  (startapp "write" todofname)
)
(defun chktodo ( / dwgname todoname found)
(setq dwgname (GETVAR "dwgname"))
(setq dwgname (substr dwgname 1 (- (strlen dwgname) 4)))
(setq todoname (strcat (getvar "dwgprefix")  dwgname ".txt" ))
(setq found (findfile todoname))
(if (/= found nil)
(startapp "write" todoname)
(princ "Todo")
)
)

Posted (edited)

Try this :

 

(vl-load-com)
(defun c:todo ( / todoname fp)
  (setq todoname (strcat (getvar 'dwgprefix) (vl-filename-base (getvar 'dwgname)) ".txt"))
  (cond ( (/= (findfile todoname) nil)
          (startapp "write" todoname)
        )
        ( (setq fp (open todoname "w"))
          (close fp)
          (startapp "write" todoname)
        )
  )  
)

 

It searches for the text file. If it finds it it opens it. If it doesn't find it, it creates it, then opens it.

Edited by dlanorh
Posted

Hello,
This does not work.
The message follows: "179062-0000018159-Fa" this file could not be found.
Check if the correct path and file name has been specified.

it lacks the rest of the filename which is still dot and white space and the rest

This:    . Martin

the entire file name is: "179062-0000018159-Fa. Martin.dwg"

Thanks for your help
Martin
 

Posted

With notepad, there seems to be no problem. Everything works. But it does not work in WordPad.

Posted (edited)

Try this

 

(defun c:todo ( / dname todoname )
  (setq todoname (strcat (getvar 'dwgprefix) (substr (setq dname (getvar 'dwgname)) 1 (- (strlen dname) 4)) ".txt"))
  (cond ( (/= (findfile todoname) nil)
          (startapp "write" (strcat "\"" todoname "\""))
        )
        ( (setq fp (open todoname "w"))
          (close fp)
          (startapp "write" (strcat "\"" todoname "\""))
        )
  )  
)

 

Bookmark this page for startapp reference purposes. HERE

Edited by dlanorh
  • Thanks 1
Posted

Hello,
this works only if a file "txt" already exists then it will be opened.
But if there is no "txt" comes an error message "nil"

Thank you for your help

Greetings Martin

 

Posted

It works on my system when the text file exists or not, unless of course the ". Martin" is literal and you have underlined text in the drawing name.

Posted

Oh sorry
yes it really works.
I did something wrong.

Thank you very much for your great help

Thank you
Greetings Martin

Posted

FWIW, vl-filename-base should still perform as expected even if the filename in question contains periods, observe:

_$ (vl-filename-base "179062-0000018159-Fa. Martin.dwg")
"179062-0000018159-Fa. Martin"

Hence the code could be written:

(defun c:todo ( / d f )
    (if (or (findfile (setq f (strcat (getvar 'dwgprefix) (vl-filename-base (getvar 'dwgname)) ".txt")))
            (and (setq d (open f "w")) (not (close d)))
        )
        (startapp "write" (strcat "\"" f "\""))
    )
    (princ)
)

 

  • Like 1
  • Thanks 1
Posted
3 hours ago, martinle said:

Oh sorry
yes it really works.
I did something wrong.

Thank you very much for your great help

Thank you
Greetings Martin

 

Perhaps you didn't make a mistake. I noticed an error once I posted the lisp and edited. You may have copied the unedited lisp while I was editing it.

  • Thanks 1
Posted

Thank you all it works

 

Martin

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...