Author Topic: force network synch to update styles?  (Read 13049 times)

0 Members and 1 Guest are viewing this topic.

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #15 on: February 27, 2015, 11:34:11 PM »
I couldn't figure out how to find the file where dref is targeting, so I just manually select the source file.

Quite a bit more difficult with LISP than with .NET, but the files you're after are the same.

<RoamableRootPrefix> + "Project Management\\ShortcutFolders.xml will provide the WorkingFolder/ShortcutFolder XmlNode's path XmlAttribute's string value, which then allows you to locate <ShortcutFolderPathValue> + "\\_shortcuts\\<YourC3dObjectType>\\" in order to iterate the XML files contained within, and WCMATCH the XML file with the "<C3DObjectName>_<GUID>.xml" file naming convention.

At this point, you open the "<C3DObjectName>_<GUID>.xml" file, and obtain ProjectInfo/Shortcuts/Shortcut/DwgRelPath XmlNode's path XmlAttribute's value, or ProjectInfo/Shortcuts/Shortcut/Criteria/File XmlNode's name XmlAttribute's value for full file path.

HTH
Pretty slick. I didn't realize that info was stored anywhere. Of course, without the ability to set the style, I've hit a brick wall. I've put learning to code in .net off for too long because I was "busy" or just being lazy, and now it's a real issue.
Can the structure/pipe style be successfully set in the .net api?
Time to start studying.
Thanks, guys.  :|

Yeah, for an internal database, you'd think the host drawing would simply reference the parent drawing (but no). Haha

Not sure if .NET API can do that (yet), but just happen to know the best non-Autodesk Civil 3D developer there is - I'll see what he thinks - if it can, maybe we'll slap a LispFunction Method together? *not sure*

Cheers
"How we think determines what we do, and what we do determines what we get."

alanjt

  • Needs a day job
  • Posts: 5327
  • Standby for witty remark...
Re: force network synch to update styles?
« Reply #16 on: February 28, 2015, 01:51:59 AM »
I couldn't figure out how to find the file where dref is targeting, so I just manually select the source file.

Quite a bit more difficult with LISP than with .NET, but the files you're after are the same.

<RoamableRootPrefix> + "Project Management\\ShortcutFolders.xml will provide the WorkingFolder/ShortcutFolder XmlNode's path XmlAttribute's string value, which then allows you to locate <ShortcutFolderPathValue> + "\\_shortcuts\\<YourC3dObjectType>\\" in order to iterate the XML files contained within, and WCMATCH the XML file with the "<C3DObjectName>_<GUID>.xml" file naming convention.

At this point, you open the "<C3DObjectName>_<GUID>.xml" file, and obtain ProjectInfo/Shortcuts/Shortcut/DwgRelPath XmlNode's path XmlAttribute's value, or ProjectInfo/Shortcuts/Shortcut/Criteria/File XmlNode's name XmlAttribute's value for full file path.

HTH
Pretty slick. I didn't realize that info was stored anywhere. Of course, without the ability to set the style, I've hit a brick wall. I've put learning to code in .net off for too long because I was "busy" or just being lazy, and now it's a real issue.
Can the structure/pipe style be successfully set in the .net api?
Time to start studying.
Thanks, guys.  :|

Yeah, for an internal database, you'd think the host drawing would simply reference the parent drawing (but no). Haha

Not sure if .NET API can do that (yet), but just happen to know the best non-Autodesk Civil 3D developer there is - I'll see what he thinks - if it can, maybe we'll slap a LispFunction Method together? *not sure*

Cheers
Hell, I wish you could click on a surface, etc. dref and it would tell you where it's referencing.

Man, I would be forever appreciative, if it works and you have the time. If it isn't available in dotNET, does that mean it could be possible with C+? I know I read somewhere about certain properties weren't available in the NET api, but could be accomplished using COM. The ability to set it with COM is there, it just doesn't seem to work when accessing it via LISP.
This would solve my issue with pipe networks not updating dref styles, and breaking a part's connection to the list if you edit an optional property at the object level. The rest of the code I posted works w/o issue, I just can't get it to set the damn structure style.

This has been the wake up call I've needed and I'll be spending the weekend digging into dotNET. Starting advice?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #17 on: February 28, 2015, 03:28:54 AM »
To clarify, much of what we can do in .NET API, particularly in terms of Civil 3D, still uses COM (which may make no sense).

Similar to LISP, not everything about C3D APIs is exposed to even .NET, or ObjectARX - COM only.

However, .NET API has the ability to use 'pure' .NET (to open those version specific XML files as XmlDocument, and iterate the XmlNodes, reading the corresponding XmlAttribute values, etc), and COM (to access the AECC Objects Style, etc) in concert, using early/late binding in earlier .NET Frameworks, or dynamics as an advent in newer Frameworks.

In any event, you know we'll all pitch in where we can.

Kerry started a good thread here on how to get started with .NET API (linked below), and I've previously helped others with similar requests here and here:

http://www.cadtutor.net/forum/showthread.php?90945-Which-program-to-work-with-VB.net

http://www.cadtutor.net/forum/showthread.php?90713-Can-AutoCAD-2015-be-used-with-Visual-Studio-2015&p=622866&viewfull=1#post622866

Quote from: BlackBox
Also, these may be of use:

http://forums.autodesk.com/t5/net/autocad-2015-net-wizard/m-p/5169991#M41454

http://www.theswamp.org/index.php?topic=47450.0



« Last Edit: February 28, 2015, 03:34:22 AM by BlackBox »
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 3942
  • C3D user & customizer
Re: force network synch to update styles?
« Reply #18 on: February 28, 2015, 12:21:54 PM »

Can the structure/pipe style be successfully set in the .net api?

This has been the wake up call I've needed and I'll be spending the weekend digging into dotNET. Starting advice?
Yes, the structure style can be changed in .NET, Here's a very quick sample that demonstrates how:
Code - C#: [Select]
  1.         [CommandMethod("ChangeStructStyle")]
  2.         public void changestructstyle()
  3.         {
  4.             Document doc = Application.DocumentManager.MdiActiveDocument;
  5.             Editor ed = doc.Editor;
  6.             PromptEntityOptions entOpts = new PromptEntityOptions("\nSelect a structure:");
  7.             entOpts.AllowNone = true;
  8.             entOpts.SetRejectMessage("...not a Civil3D structure.");
  9.             entOpts.AddAllowedClass(typeof(Structure), true);
  10.             PromptEntityResult entRes = ed.GetEntity(entOpts);
  11.             if (entRes.Status != PromptStatus.OK)
  12.                 return;
  13.             using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
  14.             {
  15.                 Structure structure = (Structure)entRes.ObjectId.GetObject(OpenMode.ForWrite);
  16.                 ObjectId styleId = CivilApplication.ActiveDocument.Styles.StructureStyles["Basic"];
  17.                 structure.StyleId = styleId;
  18.                 tr.Commit();
  19.             }
  20.         }
  21.  

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #19 on: February 28, 2015, 05:14:06 PM »

Can the structure/pipe style be successfully set in the .net api?

This has been the wake up call I've needed and I'll be spending the weekend digging into dotNET. Starting advice?
Yes, the structure style can be changed in .NET, Here's a very quick sample that demonstrates how:
Code - C#: [Select]
  1.         [CommandMethod("ChangeStructStyle")]
  2.         public void changestructstyle()
  3.         {
  4.             Document doc = Application.DocumentManager.MdiActiveDocument;
  5.             Editor ed = doc.Editor;
  6.             PromptEntityOptions entOpts = new PromptEntityOptions("\nSelect a structure:");
  7.             entOpts.AllowNone = true;
  8.             entOpts.SetRejectMessage("...not a Civil3D structure.");
  9.             entOpts.AddAllowedClass(typeof(Structure), true);
  10.             PromptEntityResult entRes = ed.GetEntity(entOpts);
  11.             if (entRes.Status != PromptStatus.OK)
  12.                 return;
  13.             using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
  14.             {
  15.                 Structure structure = (Structure)entRes.ObjectId.GetObject(OpenMode.ForWrite);
  16.                 ObjectId styleId = CivilApplication.ActiveDocument.Styles.StructureStyles["Basic"];
  17.                 structure.StyleId = styleId;
  18.                 tr.Commit();
  19.             }
  20.         }
  21.  

Thanks for the prompt confirmation, Jeff.

Now, that leaves only the simple task of iteratively 'getting' the parent Style for each Structure, and Pipe selected from host drawing using the XmlDocuments I mention above (overwriting said Styles as needed), no?

Not sure if this can be done via ReadDwgFile() side-database, or perhaps even via Core Console in parallel (particularly if there is more than one parent drawing for the selected Structures and/or Pipes?)... Further, less 'expensive' to clone parent Style(s) to MdiActiveDocument's Database, or WBLOCK those out into ..\temp\ drawing(s), and simply insert? Side-database I presume.

Cheers
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 3942
  • C3D user & customizer
Re: force network synch to update styles?
« Reply #20 on: February 28, 2015, 06:17:22 PM »

Now, that leaves only the simple task of iteratively 'getting' the parent Style for each Structure, and Pipe selected from host drawing using the XmlDocuments I mention above (overwriting said Styles as needed), no?

Not sure if this can be done via ReadDwgFile() side-database Yes, this is quite doable., or perhaps even via Core Console in parallel (particularly if there is more than one parent drawing for the selected Structures and/or Pipes?) Not sure about this. I don't think CivilApplication is available in the CoreConsole, but have never looked into it.... Further, less 'expensive' to clone parent Style(s) to MdiActiveDocument's Database It's very simple to get the style, verify whether it exists in the current dwg, and copy if not, or WBLOCK those out into ..\temp\ drawing(s), and simply insert? Side-database I presume.

Cheers

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #21 on: February 28, 2015, 08:33:17 PM »
Sounds like we've got the makings of a simple ContextMenuExtension and/or CommandMethod regardless.

As for CC, as I understand it, the Civil* Objects don't need to be exposed per-se, as CC can NETLOAD assemblies (which would do the grunt work presumably). *not sure*

In any event, sounds like ReadDwgFile() is the way to go here.

I already have some code for obtaining the parent drawing as described above, which I'll post the next time I'm at the office/RDP.

Cheers
"How we think determines what we do, and what we do determines what we get."

alanjt

  • Needs a day job
  • Posts: 5327
  • Standby for witty remark...
Re: force network synch to update styles?
« Reply #22 on: March 02, 2015, 08:23:33 AM »
I found the "export to" function for styles. Does that not work? How do you wblock out a style when you have to have a reference object to create a style object to wblock out, or can you wblock portions of the database?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Jeff_M

  • King Gator
  • Posts: 3942
  • C3D user & customizer
Re: force network synch to update styles?
« Reply #23 on: March 02, 2015, 08:48:28 AM »
Alan, forget Wblock, the ExportTo works fine.

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #24 on: March 02, 2015, 02:29:05 PM »
Alan, forget Wblock, the ExportTo works fine.

This.
"How we think determines what we do, and what we do determines what we get."

alanjt

  • Needs a day job
  • Posts: 5327
  • Standby for witty remark...
Re: force network synch to update styles?
« Reply #25 on: March 02, 2015, 04:00:29 PM »
Alan, forget Wblock, the ExportTo works fine.
Right on. Just going on the previous post. Not like I have any use for this information just yet.  The joys of learning a new language.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #26 on: March 02, 2015, 04:11:15 PM »
... The joys of learning a new language.

Which language did you decide to learn (i.e., C#, VB, etc.)? :-)

[Edit] - Also, here's an example of ExportTo() Method, that discusses the importance of StyleConflictResolverType.



... Say C#, say C#, say C#
« Last Edit: March 02, 2015, 04:14:34 PM by BlackBox »
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 3942
  • C3D user & customizer
Re: force network synch to update styles?
« Reply #27 on: March 02, 2015, 05:12:58 PM »

Which language did you decide to learn (i.e., C#)? :-)

....the importance of StyleConflictResolverType.

And the just as important knowledge that the StyleConflictResolverType doesn't always work as expected....

alanjt

  • Needs a day job
  • Posts: 5327
  • Standby for witty remark...
Re: force network synch to update styles?
« Reply #28 on: March 02, 2015, 07:58:27 PM »
... The joys of learning a new language.

Which language did you decide to learn (i.e., C#, VB, etc.)? :-)

[Edit] - Also, here's an example of ExportTo() Method, that discusses the importance of StyleConflictResolverType.



... Say C#, say C#, say C#
C# seemed the choice over vb, and you just confirmed it. :)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #29 on: March 03, 2015, 01:51:46 AM »

Which language did you decide to learn (i.e., C#)? :-)

....the importance of StyleConflictResolverType.

And the just as important knowledge that the StyleConflictResolverType doesn't always work as expected....

Yikes - what do you do then, second attempt, or iterate the source/target style's settings?
"How we think determines what we do, and what we do determines what we get."