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

0 Members and 1 Guest are viewing this topic.

BlackBox

  • King Gator
  • Posts: 3770
Civil 3D Data Shortcuts | Working Folder
« on: July 02, 2012, 04:02:14 PM »
Is there a way to programmatically change the Civil Application's Working Folder Property in Civil 3D 2011 or newer?

Attempting to dig through the Civil 3D .NET API, I came across the AssociateShortcutsProjectId Property, but this appears to require a newer build of AeccDbMdg.dll (9.0.1780.0) than that which is included with Civil 3D 2012 (9.0.1619.0).


** Edit - Another reference: http://docs.autodesk.com/CIV3D/2012/ENU/API_Reference_Guide/net/!!MEMBERTYPE_Properties_Autodesk__Civil__Settings__SettingsRoot.htm


I'm not even sure if this Property is what I am after (in the Working Folder), but it's appearing as though this Feature has not been exposed to the versions of the Civil 3D API that I would need to use anyway.

Any guidance or clarification would be greatly appreciated.

TIA
« Last Edit: July 02, 2012, 04:19:26 PM by RenderMan »
"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 #1 on: July 02, 2012, 07:47:51 PM »
AssociateShortcutsProjectId was available in C3D2010, but it only lets you set the project, not the working folder. That version info you see on the help page is just the version that was searched by their new automatic API help constructor, don't pay much attention to that.

I have never been able to find a way to set the WorkingFolder. I know I could sure put it to use.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Civil 3D Data Shortcuts | Working Folder
« Reply #2 on: July 02, 2012, 08:18:14 PM »
I should expand that reply to say I know WHERE the data is stored, I just haven't found a way to edit it while C3D is open. The working folder is saved in an XML file, this can be edited outside of C3D and it will be used the next time C3D loads. But I cannot get C3D to re-read the XML file after it has been started. And I'm not sure why C3D is not saving the Current WorkingFolder in the WorkingFolders.xml, it's like this is the default folder to use if those in the Shortcutfolders cannot be found.
"C:\Users\<UserName>\AppData\Roaming\Autodesk\C3D 2012\enu\Project Management\ShortcutFolders.xml"
"C:\Users\<UserName>\AppData\Roaming\Autodesk\C3D 2012\enu\Project Management\WorkingFolders.xml"

Anyway, this may, or may not, help with what you want to do.

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Data Shortcuts | Working Folder
« Reply #3 on: July 02, 2012, 08:46:07 PM »
Thanks for the clarification, Jeff.

As I'm sure you and other C3D users are, developer kind or not, I'm disappointed in Autodesk's lack of foresight, that one would want to be able to add some working folder automation given that Autodesk failed to implement an appropriate DocumentBecameCurrent Event monitor that would/should automagically change the working folder based upon if the ActiveDocument is associated with a given project.

That and the fact that the Set Working Folder dialog precludes one from navigating to the destination location via shortcut (.LNK), is equally frustrating.

/vent
"How we think determines what we do, and what we do determines what we get."

wooz

  • Guest
Re: Civil 3D Data Shortcuts | Working Folder
« Reply #4 on: July 05, 2012, 09:59:28 AM »
To re-read the content from the XML use the command "REFRESHSHORTCUTNODE".  We use a document management system with some other customizations that allow us to build out the path to the working directory.  My addin checks the ShortcutFolders.xml to see if it is in the list, if it is the it sets the attribute "current=1" and all others =0.  If it does not then it writes it to the xml file. 

This method is kind of a hack but works pretty well until Autodesk provides something better. 

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Civil 3D Data Shortcuts | Working Folder
« Reply #5 on: July 05, 2012, 11:31:54 AM »
Thanks for that bit of info, wooz! Sure would've been nice of the folks at ADN to have let me know about that command. Your 'hack' is nearly identical to what I had tried to implement, but failed due to not knowing about the one command.

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Data Shortcuts | Working Folder
« Reply #6 on: July 05, 2012, 11:38:00 AM »
Thanks for that bit of info, wooz!

1+

Awesome; thanks, wooz! :beer:
"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 #7 on: November 16, 2012, 07:33:58 AM »
Could someone confirm that this is issue has, or has not, been addressed in Civil 3D 2013?
"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 #8 on: November 16, 2012, 09:24:57 AM »
Addressed how? From what I can tell, it was/is working as designed. (May not be how you or I would've done it, but someone thought it was the 'right' thing to do.)

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Data Shortcuts | Working Folder
« Reply #9 on: November 16, 2012, 09:37:03 AM »
Thanks for the prompt reply, Jeff.

Addressed how?

As I understand it for Civil 3D 2011, and 2012, when one switches documents, the Toolspace palette's Propsector, and Settings tabs are updated to reflect the MdiActiveDocument's data (style, etc.), yet the Working Folder data remains static.

I would consider this to be addressed, by implementing the necessary code behind (and perhaps additional XML support?) to allow the DocumentBecameCurrent Event to trigger an update of the Working Folder data as well.

My $0.02

From what I can tell, it was/is working as designed. (May not be how you or I would've done it, but someone thought it was the 'right' thing to do.)

I am not arguing the point of right or wrong here, I am simply trying to confirm that the behavior observed in previous releases (2011, 2012, etc.) has, or has not, been changed.
"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 #10 on: November 16, 2012, 09:52:58 AM »
OK, gotcha. I'm still just waking up and had to go do some testing to jog my memory as to what the issue is. 2013 behaves the same as previous versions...opening a drawing whose shortcut folder has been saved with the dwg, while the working folder is set to another folder, results in the project not being found.

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Data Shortcuts | Working Folder
« Reply #11 on: November 16, 2012, 10:00:36 AM »
OK, gotcha. I'm still just waking up and had to go do some testing to jog my memory as to what the issue is. 2013 behaves the same as previous versions...opening a drawing whose shortcut folder has been saved with the dwg, while the working folder is set to another folder, results in the project not being found.

No worries; thank you, Sir.
"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 #12 on: January 09, 2013, 08:35:03 PM »
I've been contemplating this topic, and wanted to know how one would get the current project association from a given MdiActiveDocument (presumably via some Civil Namespace)?
"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 #13 on: January 09, 2013, 11:19:33 PM »
I had thought that this should do it:
public string AssociateShortcutProjectId { get; set; }

but it returns an empty string whether there is a project associated to the drawing or not. Still searching...

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Data Shortcuts | Working Folder
« Reply #14 on: January 10, 2013, 12:32:06 AM »
Thanks for looking, Jeff.  :-)
"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 #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."