Jump to content

Recommended Posts

Posted

Need help with following, I want to write lisp to save drawing. I have the following:
 

(setq dxfname (strcat (vl-filename-base (getvar "dwgname"))))
(command "SAVEAS" "DXF" "VERSION" "2000" "" (strcat (getvar "dwgprefix") dxfname))


And when there already is a drawing with the same name, I get this message: "A drawing with this name already exists." and in that case I'd like to have DCL pop up and ask me if I want to replace it or not. My problem is how to save that command line text to create if function, something like
(if
(= message "A drawing with this name already exists.")
...

)

Or if there is any other way to do what I want, please write your solutions, thanks!

Posted

This is quite a simple one to use@

http://www.lee-mac.com/popup.html

 

put in something like 

(setq Answer (LM:popup "Title Text" "This is a test message." 4) )
(if (= Answer 6)
  (progn
    (princ "Yes")
  ) ;end progn
  (progn
    (princ "No")
  ) ;end progn
) ;end if

 

Posted
14 minutes ago, Steven P said:

This is quite a simple one to use@

http://www.lee-mac.com/popup.html

 

put in something like 

(setq Answer (LM:popup "Title Text" "This is a test message." 4) )
(if (= Answer 6)
  (progn
    (princ "Yes")
  ) ;end progn
  (progn
    (princ "No")
  ) ;end progn
) ;end if

 


Thanks for this, but I created the DCL pop up, that is not the problem here. Problem is how to know if it needs to ask for replacement. for example here, if a drawing already exist (message "A drawing with this name already exists.") then (setq Answer (LM:popup "Save as dxf" "Overwrite existing dxf?" 1)). If not then just save as, no pop up needed. Hope I explained enough

Posted

I was answering the worng thing then, how about this:

 

(

(if dxfname
  (progn
    (princ "File Exists)
  ) ; End progn
  (progn
    (princ File Doesn't exist")
  ) ; End progn
) ; end if

 

Posted
8 hours ago, Steven P said:

I was answering the worng thing then, how about this:

 

(

(if dxfname
  (progn
    (princ "File Exists)
  ) ; End progn
  (progn
    (princ File Doesn't exist")
  ) ; End progn
) ; end if

 


No, even though drawing is not saved, dxfname variable exist (Drawing1, Drawing2,...)

Posted (edited)

You could try 

 

(if (= (getvar 'DWGTITLED) 0)
  (princ "Drawing Not Saved")
  (princ "drawing Saved")
)

 

to find out if the drawing has been saved

Edited by Steven P

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...