Author Topic: Any Clue where to get Style Overrides?  (Read 3186 times)

0 Members and 1 Guest are viewing this topic.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Any Clue where to get Style Overrides?
« on: May 14, 2016, 11:21:15 PM »
For Civil 3D, I want to override a pipe's style in a profile view (profileviewpart)...anyone know if that's possible (in .Net I mean...I know I can do it through the profile view options)?

Looking at the profileviewpart members I'm not sure it's relevant... I think if I get the part, then it will change the style, not just set an override.  I'm thinking the override might be a graphical item somewhere but I'm not sure where.

Jeff_M

  • King Gator
  • Posts: 4100
  • C3D user & customizer
Re: Any Clue where to get Style Overrides?
« Reply #1 on: May 15, 2016, 10:12:20 AM »
This is a member of the ProfileView's GrapghOverrides. You will need to loop through the overrides looking for the profile ObjectId or name (the name of the Part). In the Override properties the Draw, OverrideStyleId, OverrideStyleName, and UseOverride are used to determine the display of the part.


« Last Edit: May 15, 2016, 10:18:09 AM by Jeff_M »

Jeff_M

  • King Gator
  • Posts: 4100
  • C3D user & customizer
Re: Any Clue where to get Style Overrides?
« Reply #2 on: May 15, 2016, 10:16:38 AM »
And here is a Pipe which has been overridden:

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Any Clue where to get Style Overrides?
« Reply #3 on: May 15, 2016, 04:37:35 PM »
Thanks for this!

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Any Clue where to get Style Overrides?
« Reply #4 on: May 15, 2016, 10:33:55 PM »
found tweaking this before drawing was easier lol

Autodesk.Civil.Settings.SettingsCmdAddNetworkPartsToProf

If I get really ambitious I'll dig into the graphic overrides.

Was that snoop you used to display that info?

Jeff_M

  • King Gator
  • Posts: 4100
  • C3D user & customizer
Re: Any Clue where to get Style Overrides?
« Reply #5 on: May 16, 2016, 09:53:07 AM »
No, I just set a breakpoint in the code to stop right after I opened the ProfileView entity for Read. The screenshots are from the Locals window in VS2013

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Any Clue where to get Style Overrides?
« Reply #6 on: May 16, 2016, 08:53:14 PM »
Holy cow! really need to learn visual studio better lol

ChrisCarlson

  • Guest
Re: Any Clue where to get Style Overrides?
« Reply #7 on: May 17, 2016, 08:01:55 AM »
That's why I told you to learn the basics of C# and VS first, then AutoCAD specific.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Any Clue where to get Style Overrides?
« Reply #8 on: May 17, 2016, 04:22:03 PM »
That's why I told you to learn the basics of C# and VS first, then AutoCAD specific.

You're right. I tend to use C# express edition but looks like I'm not taking advantage of what VS can really do. 

Getting the graphic override is actually pretty difficult.  I iterated through both the profile view part and the graphic override, but there appeared to be no way to consolidate the two (the part with the style override), not that I could see easily though. If you know how I'd love to get your input. 

Jeff_M

  • King Gator
  • Posts: 4100
  • C3D user & customizer
Re: Any Clue where to get Style Overrides?
« Reply #9 on: May 17, 2016, 05:12:40 PM »
Visitor, the c# Express works fine, although the 2013 & 2015 Community editions are a bit more powerful while still being free.

Getting the Graphic Override is actually quite simple. What I'm finding in my quick test to show you how to set the override, however, is that the API is broke....passing the StyleName or StyleId both throw unhandled exceptions because the API is expecting ONLY a ProfileStyle ObjectId or Name.

So, here's the code I was testing with:
Code - C#: [Select]
  1.             using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
  2.             {
  3.                 var pv = (ProfileView)tr.GetObject(entRes.ObjectId, OpenMode.ForRead);
  4.                 var partnametooverride = "Pipe - (1)";
  5.                 var styleId = CivilApplication.ActiveDocument.Styles.PipeStyles["Pipe Crossing Pipe (Sanitary)"];
  6.                 foreach(var overide in pv.GraphOverrides)
  7.                 {
  8.                     if(overide.ProfileName==partnametooverride)
  9.                     {
  10.                         overide.OverrideStyleId = styleId;
  11.                         break;
  12.                     }
  13.                 }
  14.                 tr.Commit();
  15.             }
  16.  
I'm going to fire off a query to ADN support about the exception...

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Any Clue where to get Style Overrides?
« Reply #10 on: May 17, 2016, 05:29:35 PM »
Think we're saying the same thing...that there's no way to consolidate the two (the override with the part)...or are you able to get the profile view to show the pipe with the override?  I could not. I got as far as you did (getting the selected part and the profile view overrides) but couldn't get the part to change.

Visitor, the c# Express works fine, although the 2013 & 2015 Community editions are a bit more powerful while still being free.

Getting the Graphic Override is actually quite simple. What I'm finding in my quick test to show you how to set the override, however, is that the API is broke....passing the StyleName or StyleId both throw unhandled exceptions because the API is expecting ONLY a ProfileStyle ObjectId or Name.

So, here's the code I was testing with:
Code - C#: [Select]
  1.             using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
  2.             {
  3.                 var pv = (ProfileView)tr.GetObject(entRes.ObjectId, OpenMode.ForRead);
  4.                 var partnametooverride = "Pipe - (1)";
  5.                 var styleId = CivilApplication.ActiveDocument.Styles.PipeStyles["Pipe Crossing Pipe (Sanitary)"];
  6.                 foreach(var overide in pv.GraphOverrides)
  7.                 {
  8.                     if(overide.ProfileName==partnametooverride)
  9.                     {
  10.                         overide.OverrideStyleId = styleId;
  11.                         break;
  12.                     }
  13.                 }
  14.                 tr.Commit();
  15.             }
  16.  
I'm going to fire off a query to ADN support about the exception...

Jeff_M

  • King Gator
  • Posts: 4100
  • C3D user & customizer
Re: Any Clue where to get Style Overrides?
« Reply #11 on: May 17, 2016, 05:34:24 PM »
Yeah, as long as it is throwing the exception when passing the Pipe StyleId, it will never change. Will keep you posted on what ADN says about it.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Any Clue where to get Style Overrides?
« Reply #12 on: May 17, 2016, 05:35:41 PM »
Yeah, as long as it is throwing the exception when passing the Pipe StyleId, it will never change. Will keep you posted on what ADN says about it.

Thanks!