Author Topic: Civil 3D Data Shortcuts | Working Folder  (Read 11184 times)

0 Members and 1 Guest are viewing this topic.

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Data Shortcuts | Working Folder
« Reply #15 on: January 10, 2013, 11:12:13 AM »
Another aspect of this, is not loading the code unless Civil 3D... We're currently using Civil 3D 2011/2012, and auto-load apps via registry, but how would I go about this?  :?

For example, I can prevent the Events from being registered in Initialize() if the product key doesn't match up, but is there a way of preventing the code from being instantiated altogether, unless the host application is Civil 3D?
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Civil 3D Data Shortcuts | Working Folder
« Reply #16 on: January 10, 2013, 01:18:12 PM »
Not sure if it's the right, or best, way to do it but we use a loader dll to determine if the current profile contains IsPureAcadProfile and whether it is 1 or 0. We then load our dll if it is 0 with the loader dll.

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Data Shortcuts | Working Folder
« Reply #17 on: January 14, 2013, 10:01:08 AM »
My kludge mostly works, when switching between multiple open Documents it does exactly what I'm after, but is not correctly being enacted at Document open for some reason.

I think it has something to do with timing, as perhaps something is not being initialized fully prior to my call to SendStringToExecute()... Given that this is an Aecc-only Command?  :?

In any event, when I open a Document, the XML is being updated correctly, but the call to update the working folder does nothing (again, only at drawing open). This exact same line is copied into my DocumentBecameCurrent Event handler and works (only when switching Documents).

Code - C#: [Select]
  1. //<snip>
  2.  
  3.         void IExtensionApplication.Initialize()
  4.         {
  5.             DocumentCollection acDocs = acApp.DocumentManager;
  6.             Document doc = acDocs.MdiActiveDocument;
  7.  
  8.             acDocs.DocumentBecameCurrent += _OnDocumentBecameCurrent;
  9.  
  10.             _SetWorkingFolder(doc);
  11.  
  12.             doc.SendStringToExecute("RefreshShortcutNode\n", false, false, false);
  13.         }
  14.  
  15. //<snip>
  16.  

... Since the XML is being updated correctly at drawing open, a manual call to RefreshShortcutNode at the command line is successful.

What am I overlooking here?
« Last Edit: January 14, 2013, 10:17:32 AM by RenderMan »
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Data Shortcuts | Working Folder
« Reply #18 on: January 15, 2013, 06:16:54 PM »
... Just adding onto the list of Events that _do not_ work at Drawing open: EnteringQuiescentState, DocumentActivated, and DocumentCreated.

More specifically, the code executes in these Events... The XML is updated programmatically, and the RefreshShortcutNode Command is called via SendStringToExecute()... But there is no change in Toolspace, Prospector tab, Working folder.

** Edit - Essentially, I'm having trouble determining when whatever background initialization RefreshShortcutNode needs to work, is done loading in each drawing (never mind, why is it, whatever it is, not loaded once per session!?).



Currently, the only working Event is DocumentBecameCurrent, but even then, I still have to open a given drawing, switch to a second drawing, and then back to the original drawing before the result of RefreshShortcutNode is displayed in Toolspace, Prospector tab.
« Last Edit: January 15, 2013, 06:38:08 PM by RenderMan »
"How we think determines what we do, and what we do determines what we get."