Author Topic: Simulate DWG double click  (Read 426 times)

0 Members and 1 Guest are viewing this topic.

WILL HATCH

  • Bull Frog
  • Posts: 448
Simulate DWG double click
« on: March 13, 2018, 08:16:08 PM »
Hi All,

I've got an application that displays a list of DWG files, and I'd like to be able to simulate double clicking on the file. Now this is straightforward to do with a line of code

Code - C#: [Select]
  1. System.Diagnostics.Process.Start(dwgpath);

BUT

When AutoCAD loads it complains then closes
Quote
The security system (softlock license manager)
is not functioning or is improperly installed.

Now if I already have acad open then it's fine.
Anybody run into this before?

Thanks!

huiz

  • Swamp Rat
  • Posts: 822
  • Certified Prof C3D
Re: Simulate DWG double click
« Reply #1 on: March 14, 2018, 09:24:34 AM »
I've seen the error a looong time ago. I'm not sure if I would receive the error again with the newest versions, also I do have single user license now so I probably can't reproduce.


If you chain the dwg file to acad.exe instead of the launcher, does it work? You could change your function so that it starts the latest acad.exe with the dwg-file as a parameter.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

dgorsman

  • Water Moccasin
  • Posts: 2337
Re: Simulate DWG double click
« Reply #2 on: March 14, 2018, 12:38:55 PM »
I vaguely remember seeing something like that before.  I don't think it was related to the type of license or version, but trying to do that "double click simulation" process.

I'll second the recommendation of passing it as an argument to the actual application; you'll want to include things like profile, ARX extensions (via "/ld" and "/product" arguments) as appropriate.  Double-clicking from an Explorer window will have the same problems of version, application (TrueView, Navisworks, Civil3D/other verticals, etc.) etc. as with your application.  You might want to consider a right-lick menu instead with a variety of appropriate "Open with/as..." options.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

WILL HATCH

  • Bull Frog
  • Posts: 448
Re: Simulate DWG double click
« Reply #3 on: March 14, 2018, 07:48:29 PM »
Thanks, that's what I suspected would be the case. I like the idea of having this just use the environment defaults. Here's a confusing bit: we have both VMs and workstations in the office and it works fine on the VM client.

I did find a solution! You guys were definitely on the right trail. I found a bit on SO that talked about finding the exe associated with the extension, I needed to pass the dwg file path to this function to get the exe associated with it.
Quote
Code - C#: [Select]
  1. public static bool HasExecutable(string path)
  2. {
  3.    var executable = FindExecutable(path);
  4.    return !string.IsNullOrEmpty(executable);
  5. }
  6.  
  7. private static string FindExecutable(string path)
  8. {
  9.    var executable = new StringBuilder(1024);
  10.    FindExecutable(path, string.Empty, executable);
  11.    return executable.ToString();
  12. }
  13.  
  14. [DllImport("shell32.dll", EntryPoint = "FindExecutable")]
  15. private static extern long FindExecutable(string lpFile, string lpDirectory, StringBuilder lpResult);

In the process of testing this I copied the filename from the file in windows explorer and pasted it into the path. Next instead of copying this full dwg file path I hit enter and Acad loaded as expected.

Thats when the lightbulb went off... this is being handled by explorer.exe so we must pass the arguments through there!

Code - C#: [Select]
  1. System.Diagnostics.Process.Start("explorer.exe", dwgpath);

huiz

  • Swamp Rat
  • Posts: 822
  • Certified Prof C3D
Re: Simulate DWG double click
« Reply #4 on: March 15, 2018, 08:16:56 AM »
Ah, good to know :-)
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.