Author Topic: How to choosing a product other than AutoCAD  (Read 2000 times)

0 Members and 1 Guest are viewing this topic.

flycoflyco

  • Mosquito
  • Posts: 3
How to choosing a product other than AutoCAD
« on: October 17, 2018, 06:39:18 AM »
Hello, I am a Korean who is studying.

Please understand me even if you don't speak English.

Recently i was wondering.

When I run AutoCAD in my program, the last executed product runs.

For example, if you run my program while working with Map3d, Map3d will run.

I want to run only Civil3d.

Below is my source code.
Code - C#: [Select]
  1.          public static void Open_Civil()
  2.         {
  3.             string progId = "AutoCAD.Application.22";//"AeccXUiLand.AeccApplication.12";
  4.             dynamic cadApp = null;
  5.             dynamic civilApp = null;
  6.  
  7.             try
  8.             {
  9.                
  10.                 cadApp = (AcadApplication)Marshal.GetActiveObject(progId);
  11.                
  12.             }
  13.             catch
  14.             {
  15.                 try
  16.                 {
  17.                     Type t = Type.GetTypeFromProgID(progId);
  18.                     cadApp = (AcadApplication)Activator.CreateInstance(t,true);
  19.                 }
  20.                 catch
  21.                 {
  22.  
  23.                 }
  24.             }
  25.             if (cadApp != null)
  26.             {
  27.                 System.Threading.Thread.Sleep(1000);
  28.                 cadApp.Visible = true;
  29.                 System.Threading.Thread.Sleep(1000);
  30.  
  31.                 dynamic aeccapp = new AeccApplication();
  32.                 aeccapp.Init(cadApp);
  33.             }
  34.         }
  35.  


I hope only Civil3d will run.
What should I do?

Thank you for reading my question.

Bryco

  • Water Moccasin
  • Posts: 1882
Re: How to choosing a product other than AutoCAD
« Reply #1 on: October 17, 2018, 03:34:21 PM »
In debug I use this under command line aurguments
Code: [Select]
/p "yourprofile" /b "C:\Users\username\Documents\Visual Studio 2017\Projects\GetThangs19.scrPerhaps a profile (/p)  will help

flycoflyco

  • Mosquito
  • Posts: 3
Re: How to choosing a product other than AutoCAD
« Reply #2 on: October 17, 2018, 08:23:23 PM »
https://drive.google.com/open?id=1gYbwfDNHHpoUE3C5JkgUxZY8K-dBrisn

Thank you for your reply.  :-)

It worked well when debugging, but it is a project to run with icon double click.



Bryco

  • Water Moccasin
  • Posts: 1882
Re: How to choosing a product other than AutoCAD
« Reply #3 on: October 17, 2018, 09:46:51 PM »
I found this (don't know if it works)
exePath = "C:\Program Files\Autodesk\AutoCAD 2016\acad.exe"
Dim p1 As Process = Process.Start(exePath, "/p /w <<ACADMPP>>")
'' Sleep for 10 second.
'Threading.Thread.Sleep(10000)

flycoflyco

  • Mosquito
  • Posts: 3
Re: How to choosing a product other than AutoCAD
« Reply #4 on: October 19, 2018, 12:10:03 AM »
Oh thank you very much. The function works well.
 :-D

Code - C#: [Select]
  1.                 string tempstr = @" /p <<C3D_Metric>> /product C3D /language ko-KR"
  2.                 ProcessStartInfo psi = new ProcessStartInfo(exePath, tempstr);
  3.                 psi.UseShellExecute = false;
  4.                 psi.WorkingDirectory = @"c:\temp";
  5.                 Process pr = Process.Start(psi);
  6.                 pr.WaitForInputIdle();
  7.                
  8.                
  9.                 while (cadApp == null)
  10.                 {
  11.                     try
  12.                     {
  13.                         System.Threading.Thread.Sleep(500);
  14.                         cadApp = (AcadApplication)Marshal.GetActiveObject(progId);
  15.                     }
  16.                     catch
  17.                     {
  18.                         System.Windows.Forms.Application.DoEvents();
  19.                     }
  20.                 }
  21.