Run command in AutoCAD OEM from external VB.NET program

Run command in AutoCAD OEM from external VB.NET program

Anonymous
Not applicable
2,628 Views
15 Replies
Message 1 of 16

Run command in AutoCAD OEM from external VB.NET program

Anonymous
Not applicable

I have an AutoCAD OEM product named "BugCAD", and a standalone VB.NET application named BugWin.  From BugWin,  I need to be able to open BugCAD, and run a command named "Callform" that is already NETLOADed.  The code below seems to be very close, but just can't quite do the job.  It opens the program fine, and tries to run the command, but thinks it's a script file that it can't find.

 

This would be a very powerful feature for both programs to interact like this.  Would appreciate any help!

 

    Private Sub BugCADToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles BugCADToolStripMenuItem.Click

        ' New ProcessStartInfo created
        Dim p As New ProcessStartInfo

        p.FileName = "C:\Program Files\Autodesk\AutoCAD OEM 2014\oem\BugCAD\bugcad.exe"

        ' Use these arguments for the process
        p.Arguments = "/b command callform"

        ' Use a hidden window
        p.WindowStyle = ProcessWindowStyle.Normal

        ' Start the process
        Process.Start(p)
    End Sub
0 Likes
Accepted solutions (1)
2,629 Views
15 Replies
Replies (15)
Message 2 of 16

FRFR1426
Collaborator
Collaborator

After the /b switch, you need to pass the path of a script file (.scr extension). Just create a text file with a .scr extension, put your callform command in it and change the arguments of bugcad.exe.

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Message 3 of 16

Anonymous
Not applicable

Thank you for your quick response Maxence.  I still get two messages:

"Can't find specified drawing file.  Pls verify it exsists."  & "Program.scr" Can't find file. 

 

Here's my new line of code:

 

' Use these arguments for the process
p.Arguments = "/b C:\Program Files\Autodesk\AutoCAD OEM 2014\oem\BugCAD\Support\callform.scr"

 

Is this the format and/or proper text that I should use?

 

I did create a text file named "callform.scr" and put it into the \Support folder in the appropriate path.  Inside the file is a line of text "callform".

 

I feel like it's very close to a solution!

thanks again!

mitch

 

0 Likes
Message 4 of 16

FRFR1426
Collaborator
Collaborator

Your script path contains spaces, you have to put it between double quotes.

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Message 5 of 16

Anonymous
Not applicable
It already is in double quotes, isn't it? Can you show me exactly how the line should look? thanks!
0 Likes
Message 6 of 16

FRFR1426
Collaborator
Collaborator
p.Arguments = "/b ""C:\Program Files\Autodesk\AutoCAD OEM 2014\oem\BugCAD\Support\callform.scr"""
Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Message 7 of 16

Anonymous
Not applicable
Getting closer... just one error message now... "callform.scr" can't find file.

Maybe this is an OEM problem? The path in the code is the Support folder uncer where the bugcad.exe file is located... that's the right place isn't it?

Thanks so much for your patience and help.
0 Likes
Message 8 of 16

Anonymous
Not applicable
Does the command "callform" inside the text file 'callform.scr' need to be in quotes?
0 Likes
Message 9 of 16

Anonymous
Not applicable

I decided try to do a similare procedure in plain AutoCAD (vs OEM), and just draw a box.  This does not give an error message, but doesn't do anything. 

In the folder 'C:\Program Files\Autodesk\AutoCAD 2014\Support', I have a text file named 'drawline.scr'.  In that file, i have the line: "LINE" "0,0,0" "1,0,0" "1,1,0" "0,1,0" "C".

 

I did that inside of a .lsp file, and it worked, but not in this situation using a .scr file.  Here's the code, why doesn't this work?

 

    Private Sub BugCADToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles BugCADToolStripMenuItem.Click

        ' New ProcessStartInfo created
        Dim p As New ProcessStartInfo

        p.FileName = "C:\Program Files\Autodesk\AutoCAD 2014\acad.exe"

        ' Use these arguments for the process
        p.Arguments = "/b ""C:\Program Files\Autodesk\AutoCAD 2014\Support\drawline.scr"""

        ' Use a hidden window
        p.WindowStyle = ProcessWindowStyle.Normal

        ' Start the process
        Process.Start(p)
    End Sub
0 Likes
Message 10 of 16

Anonymous
Not applicable
Accepted solution

looks like it is the string concatenation, just grabbed this line from some of my old code in c#:

link.Arguments = @"/b " + "\"" + Application.StartupPath + @"\someScript.scr" + "\"";

hth.

Message 11 of 16

Anonymous
Not applicable
I don't know how to convert C# to VB.net... I tried this, but doesn't work:
p.Arguments = "/b " & "C:\Program Files\Autodesk\AutoCAD OEM 2014\oem\BugCAD\Support" & "\callform.scr"""

thanks.
0 Likes
Message 12 of 16

Anonymous
Not applicable

this is a handy place to convert code vb.net to c# or vice-versa:

 

http://converter.telerik.com/

 

hth.

0 Likes
Message 13 of 16

Anonymous
Not applicable
cool, thanks!
0 Likes
Message 14 of 16

Anonymous
Not applicable
Aww... used the converter suggested by LE3, still "can't find file".

How frustrating... so close but so far... 😞
0 Likes
Message 15 of 16

Anonymous
Not applicable

have been many years that i used a script, but after re-reading and seeing what you posted:

> "LINE" "0,0,0" "1,0,0" "1,1,0" "0,1,0" "C"

 

you do not have the "-" in your script line no?, if you do, just remove all of them, and try again.

leave a line like:

 

LINE 0,0,0 1,0,0 1,1,0 0,1,0 C

 

hth

luis.-

 

 

0 Likes
Message 16 of 16

Anonymous
Not applicable

 

It works!  Here's the final code:

 


' New ProcessStartInfo created Dim p As New ProcessStartInfo p.FileName = "C:\Program Files\Autodesk\AutoCAD OEM 2014\oem\BugCAD\bugcad.exe" 'BugCAD.scr contains only the word Callform p.Arguments = "/b " + """" + "C:\Program Files\Autodesk\AutoCAD OEM 2014\oem\BugCAD\Support\bugcad.scr" + """" ' Use a hidden window p.WindowStyle = ProcessWindowStyle.Normal ' Start the process Process.Start(p) End Sub

 

The script file in the Support folder contained only the command Callform, which runs my program inside of BugCAD (AutoCAD OEM).  Several different folks contributed to the solution.  I could never have figured this out on my own, despite lots of searching.  Thanks so much!

 

0 Likes