Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Save before hatch command

10 REPLIES 10
Reply
Message 1 of 11
dmackmckenzie
705 Views, 10 Replies

Save before hatch command

Hi all!

Help! I would like to know if there is a lisp that would run everytime I run the hatch comand? I have autosave on, but I never remember to do a good clean save before I run hatch. I remember as autocad locks up and crashes! I would like a list that would prompt me to save when I hit hatch with option of yes, save or cancel. is this a tall order?

 

10 REPLIES 10
Message 2 of 11
wang890
in reply to: dmackmckenzie

i always save before i hatch. already a habit. like doing anything extreme i will save first. after crashing a few times without saving then you develop that instinct.

 

good luck finding someone willing to program one just for you.

Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19
Message 3 of 11

set the HPQUICKPREVIEW variable to OFF.

This way you can avoid the delay/crash while entering Hatch command.

Message 4 of 11

I will give that a try!
thanks.
Message 5 of 11
raghulan
in reply to: dmackmckenzie

You create a custom command to do that using .NET

 

Here is the solution!

 

object dwg_obj = cad_app.GetSystemVariable("DBMOD");

            // Check the value of DBMOD, if 0 then the drawing has no unsaved changes 
            if (System.Convert.ToInt16(dwg_obj) != 0)
            {
                MessageBoxResult result = MessageBox.Show("Do you want to Save your drawing!", "Save Drawing", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    Global.variables.db.SaveAs(Global.variables.doc.Name, true, DwgVersion.Current, Global.variables.db.SecurityParameters);
//once the save operation is complete you can run the Hatch command
SendStringToExecute("HATCH ", true, false, true);
                }
                else if (result == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

 Let me know if that helps.

 

 

Regards,

Raghulan Gowthaman Cert IV TAA, B.E,.
Senior Technical Consultant | Developer - R&D
A2K Technologies Sydney
Web : www.a2ktechnologies.com.au
www.civil3dforum.com | www.e4forums.com
www.zcodia.com.au
www.raghulangowthaman.com
Message 6 of 11
dmackmckenzie
in reply to: raghulan

Wow, thanks for the response. I am not a super user of the program, I
would say daily middle of the road. I would love to dive into civil 3d
more, but have not found the time yet.
That being said, I don't know what to do with the info you sent. I don't
even know what .net is ( see how amateur I am?) I guess I need to do some
homework.

Thanks
Message 7 of 11
raghulan
in reply to: dmackmckenzie

No worries, we all started from scratch.

Could you let me know what version of Civil3D or AutoCAD you using.

 

the following plugin works for 2013 and 2014 ver.

 

just download the rar file, extract the folder to the following location

 

 

  • (Windows XP) <drive>:\Documents and Settings\<user name>\Application Data\Autodesk\ApplicationPlugins
  • (Windows Vista or Windows 7) <drive>:\Users\<user name>\AppData\Roaming\Autodesk\ApplicationPlugins

 

more info on install/ uninstall plugins : AutoDesk

 

then start your AutoCAD and run the command "SAVH"

 

Let me know how it works.!

Regards,

Raghulan Gowthaman Cert IV TAA, B.E,.
Senior Technical Consultant | Developer - R&D
A2K Technologies Sydney
Web : www.a2ktechnologies.com.au
www.civil3dforum.com | www.e4forums.com
www.zcodia.com.au
www.raghulangowthaman.com
Message 8 of 11
dmackmckenzie
in reply to: raghulan

I have 2014. I have inserted it in the folder. After installing and
restarting I tried the savh and got the "unknown command" error. So read
the help file link and it showed the folder structure, it was one level
"deep" so I moved everything back one level. But that did not help either.
So I went back to the original folder structure to no avail.
Once that starts to work do I have to savh every time or does it do it
automatically?

Thanks for the help.
Message 9 of 11
raghulan
in reply to: dmackmckenzie

Ok, Did you extract the contents of the .zip file.

Do not please the zip file,

 

extract the contents of the zip to the "Applications plugins" folder.

Then run the command SAVH it should work.

Regards,

Raghulan Gowthaman Cert IV TAA, B.E,.
Senior Technical Consultant | Developer - R&D
A2K Technologies Sydney
Web : www.a2ktechnologies.com.au
www.civil3dforum.com | www.e4forums.com
www.zcodia.com.au
www.raghulangowthaman.com
Message 10 of 11

Load the below code and try the Hatch command.

 

This is just a modification of Lisp reactor from this webpage

 

(vl-load-com)
(vlr-command-reactor nil '((:vlr-commandWillStart . startCommand)))

(defun startCommand (calling-reactor startcommandInfo / thecommandstart)

(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq thecommandstart (nth 0 startcommandInfo))
(cond
 ((= thecommandstart "HATCH") (vla-save acadDocument)(vlax-release-object acadDocument))
 ((= thecommandstart "BHATCH") (vla-save acadDocument)(vlax-release-object acadDocument))
);cond
(princ)
);defun
(princ)

 

 

 

Message 11 of 11
dmackmckenzie
in reply to: raghulan

Tried this again. Still not recognizing the command. should I put all the files in the application plugins, without folders?

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

Post to forums  

Rail Community


Autodesk Design & Make Report