Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Using .bat to Launch AutoCAD 2015 and run script Crashes

mgorecki
Collaborator

Using .bat to Launch AutoCAD 2015 and run script Crashes

mgorecki
Collaborator
Collaborator

I have a .Net program that creates a drawing by reading a text file to get the drawing parameters.

 

The designers will use a web page to enter all of the drawing parameters.  The web page will create a .bat file and execute it.

The .bat will have commands that create a script file, launch AutoCAD 2015 and then run the script it created.

The command the batch file uses is:

"C:\Program Files\Autodesk\AutoCAD 2015\acad.exe" /product ACAD /language "en-US" /b "C:\Heat Spreader\123456HS.scr"

 

The script is simply:

netload
"C:\\Program Files\\HeatSpreader\\HeatSpreader.dll"
hs
"C:\Heat Spreader\"
123456HS

 

hs = the command to launch the .Net program

C:\Heat Spreader\ = where the text file is

123456HS = the text file the program will read (C:\Heat Spreader\123456HS.txt)

 

So if I run the .bat file, it launches AutoCAD 2015, draws a couple weird objects that go on for infinity to the left and right, then gives me a JIT error:

Application does not support just-in-time (JIT)
debugging. See the end of this message for details.

************** Exception Text **************
Autodesk.AutoCAD.Runtime.Exception: eInvalidInput
   at Autodesk.AutoCAD.DatabaseServices.Hatch.AppendLoop(HatchLoopTypes loopType, ObjectIdCollection dbObjIds)
   at HeatSpreader.CreateSideView.drawSPL(Double sideViewOffset, Double lidBodyY, Double lidFootY, Double lidFootThickness, Double overallLidThickness, Double lidCavityY, Double lidCavityDepth, Double dwg_scale, Double dwgTextHeight, Double dwg_ratio, String libPath)
   at HeatSpreader.amkrClass.HS()

 

If I just open AutoCAD 2015 and then run the script (on the command line use "scr" and select C:\Heat Spreader\123456HS.scr), it works as expected, no problems. 

 

So is there a switch or something that is causing the error/crash when using the batch file?  I don't understand why I can launch AutoCAD 2015, then run the exact same script and have it work.

 

This program was originally written in Visual Studio 2010 for AutoCAD 2010 and there was no problem running the .bat file and creating the drawing.  Just the other day I opened it in Visual Studio 2012 as my company now moved to AutoCAD 2015.

In the program properties I changed the .Net Framework to 4.5 (used to be 3.5).  I also changed the references to the 2015 ObjectARX and made them "False" to copy local.

 

Thanks

Mark

0 Likes
Reply
880 Views
4 Replies
Replies (4)

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

are you using methods like sendcommand or similar things? If so that could be a result of

  • changing from 2010 to 2015, as sending commands to commandline changed
  • working well when starting manually but not when started from script (as the script is the active command maybe blocking other options

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2025
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes

mgorecki
Collaborator
Collaborator

Hi Alfred,

No, I'm not using any "Sendcommands" in my code.  Maybe I'll put a delay in the bat file to give AutoCAD time to load before running the script.  I'm just running out of ideas.

 

Thanks again,

Mark

0 Likes

BKSpurgeon
Collaborator
Collaborator

are you able to manually netload and see what happens? or perhaps paste the code (if not too long) perhaps someone can see something wrong in there? 

0 Likes

mgorecki
Collaborator
Collaborator

Hi,

The program runs great if AutoCAD is already open.  You can run the script (which does the netload and applies the needed input) or you can manually do netload and enter the needed input.  It's just when the batch file runs, creates the script, then launches AutoCAD and plays the script that it doesn't work.

 

Best regards,

Mark

0 Likes