Jump to content

Recommended Posts

Posted

Hi guys,

 

How's the farm? :D

 

I'm having a headache here with a simple lisp that I can't fix. 

 

Just to let you know, I'm using BricsCAD. See the code below:
 

Quote

(defun c:SaveAsUserDefined ()
  (vl-load-com) ; Load the COM (Component Object Model) functions for AutoCAD
    
  ; Prompt the user for the new location and file name
  (setq new-file (getfiled "Save as" "" "dwg" 16))
  
  ; Check if the user selected a valid location/name
  (if new-file
    (progn
      ; Save the current drawing as the new file
      (vla-SaveAs (vla-get-activedocument (vlax-get-acad-object)) new-file)
      (princ (strcat "\nDrawing saved as: " new-file))
    )
    (princ "\nOperation canceled by the user.")
  )
  (princ)
)

 

 

I don't know why, when I try to use that lisp, I'm not be able to change the extension. A window appears asking me to save in some location, I choose and put a name, see below:

image.thumb.png.7a410b9e86ea3aa5b293bc8a8f80af8d.png

 

 

But when it's save, always is as .DXF extension.

 

image.png.ced5785cb621c40f2d21e83a9dad5ebe.png

 

 

Any ideas?

 

Posted

Works in AutoCAD 2022.

 

Drawing saved as: C:\SLW LISP_CAD Files\DCL Testing\Testing.dwg

Posted

Maybe use (command "saveas" .... it will ask for extra details.

  • Agree 1
Posted

This is the similar line I use, I have the version at the end of it, not sure if that makes a difference? BricsCAD can be funny sometimes with VLA - commands I believe.

 

(vla-SaveAs (vla-get-ActiveDocument (vlax-get-acad-object)) (strcat (getvar "dwgprefix") myfilename ".dwg") ac2010_dwg)

 

 

(One of our clients lives in the past with ac2010, maybe I should update this one day)

  • Like 1
Posted

For opening files :

(setq new-file (getfiled "Save as" "" "dwg" 16))

 

For saving files :

(setq new-file (getfiled "Save as" "" "dwg" 1))

Posted

Hi guys,

 

Thanks for all your reply.

 

@Steven P's answer was pretty resolute for me.

 

If you have BricsCAD or have the same problem with AutoCAD, I'll be sharing the Lisp Routine below:

 

Quote

(defun c:zzzzzz()
   (vl-load-com) ; Load COM (Component Object Model) functions into AutoCAD

   ; Prompt the user for the new location and name of the file
   (setq new-file (getfiled "Save as" "" "dwg" 16))
  
   ; Check if the user selected a valid location/name
   (if new-file
     (progn
       ; Save the current drawing as the new file
       (vla-SaveAs (vla-get-ActiveDocument (vlax-get-acad-object)) new-file ac2010_dwg)
       (princ (strcat "\nDrawing saved as: " new-file))
     )
     (princ "\nOperation canceled by the user.")
   )
   (prince)
)

 

 

Thank you all for try to help me !!

 

Best wishes,

 

Rodrigo Brigido.

  • Like 1

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