Author Topic: Civil 3d: Why Doesn't GeneralSegmentLabel.StyleName = "" Work?  (Read 1706 times)

0 Members and 1 Guest are viewing this topic.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Trying to change a line / curve label using GeneralSegmentLabel.StyleName = ""; but it throws this error.

Am I doing it incorrectly? 

Code - C#: [Select]
  1. foreach (ObjectId entid in mycoll)
  2.                 {
  3.  
  4.                     GeneralSegmentLabel oNoteLabel = (GeneralSegmentLabel)myT.GetObject(entid, OpenMode.ForRead);
  5.  
  6.                     if (oNoteLabel.StyleName.ToString().Contains("partialnamehere"))
  7.                     {
  8.                         oNoteLabel.StyleName = "styleIwant";
  9.                     }
  10.  

huiz

  • Swamp Rat
  • Posts: 917
  • Certified Prof C3D
Re: Civil 3d: Why Doesn't GeneralSegmentLabel.StyleName = "" Work?
« Reply #1 on: August 31, 2015, 04:35:36 AM »
It says the Label Style Name does not exist. Are you sure it exists in the drawing?

I use the .StyleName property too, with other Civil3D objects, and have no problem. To be sure it works fine I always use a Transaction and open the objects ForWrite.
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.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Civil 3d: Why Doesn't GeneralSegmentLabel.StyleName = "" Work?
« Reply #2 on: August 31, 2015, 05:11:45 AM »
It says the Label Style Name does not exist. Are you sure it exists in the drawing?

I use the .StyleName property too, with other Civil3D objects, and have no problem. To be sure it works fine I always use a Transaction and open the objects ForWrite.

Positive it's in there but will try the write thing. In fact, I changed it manually, then had it list the name to be sure. Really strange :/

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Civil 3d: Why Doesn't GeneralSegmentLabel.StyleName = "" Work?
« Reply #3 on: August 31, 2015, 10:04:07 AM »
You cannot use a Child Stylename when assigning the StyleName property. Get, and use, the ObjectId instead.