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

custom buttons with script-like functionality. Help me get started

1 REPLY 1
Reply
Message 1 of 2
tmblackflag
397 Views, 1 Reply

custom buttons with script-like functionality. Help me get started

Hello,

 

I would like to build a custom button that mimics the FDO - Save as AutoCAD drawing functionality. Clicking this button brings up a wizard with too many clicks for how often the users will do it.

 

They will not want to load a script so a custom button is required. Also, I need to be able to dynamically set the new saved file name based on the source DWG file name.

 

What documentation should I be reviewing to get started with this? thanks.

1 REPLY 1
Message 2 of 2
tcorey
in reply to: tmblackflag

(vl-load-com)

(defun c:whatever(/ dwgnm dwgfld nmandfld)
  (setvar "FILEDIA" 0)
  (setq dwgnm (substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME")) 4)))
  (setq dwgfld (getvar "dwgprefix"))
  (setq nmandfld (strcat dwgfld dwgnm "_FDO.dwg"))
  (alert nmandfld)
	(vl-cmdf "MAPEXPORTCURRENTMAPTODWG" nmandfld)
  (setvar "FILEDIA" 1)
  (princ)
  
  )

 

This code will export the current map as a dwg of the same name as the current drawing, but with "_FDO" appended. It saves the new drawing to the same folder as the current drawing. You might want to remove the alert. I put it there so the user will be told what file is being saved, but it's not critical. And, of course, you will want to change my c:whatever nomenclature to a name that makes sense to you.

 

Is this what you were looking to do? If you don't know how to put this on a button, read up on the CUI, including how to create a new command and how to add a command to a ribbon panel.

 

Tim

 

 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut

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

Post to forums  

Autodesk Design & Make Report

”Boost