Unable to set FeatureLine.Name property

Unable to set FeatureLine.Name property

adamg23
Participant Participant
327 Views
2 Replies
Message 1 of 3

Unable to set FeatureLine.Name property

adamg23
Participant
Participant

Hello,

I am trying to create a series of feature lines using the .Net API and am running into an issue. I want to allow the user to set the name of each feature line. When I try to do that by setting featureLine.Name = "Custom Name" I can see that the featureLine.Name property has been changed but when I check in the actual drawing the Name property is blank. 

 

I noticed while playing around in Civil 3D that when I select a feature line there is an option to Apply Feature Line Names. This opens a dialogue window which contains a checkbox for the Name property and a textbox that allows me to enter a name for the feature line. If I open uncheck this box it will remove any name that I have entered previously. Is there a call I need to be making through the API to set the checkbox property in that window to true in order to allow the name to be set and visible?

Thank you in advance!

0 Likes
Accepted solutions (1)
328 Views
2 Replies
Replies (2)
Message 2 of 3

hippe013
Advisor
Advisor
Accepted solution

Without seeing your code, it is tough to tell, but it sounds to me that you are not committing your transaction. This is quite often the case as it is something that is easy to forget. If that is not it, then please post your code. 

 

The following code works:

 

Dim opt As New PromptEntityOptions(vbCrLf & "Select Featureline: ")
opt.SetRejectMessage(vbCrLf & "Selected Entity must be a Featureline. Try again.")
opt.AddAllowedClass(GetType(FeatureLine), False)
Dim res As PromptEntityResult = ed.GetEntity(opt)
If res.Status <> PromptStatus.OK Then
   Exit Sub
End If

Using tr As Transaction = db.TransactionManager.StartTransaction
   Dim fl As FeatureLine = tr.GetObject(res.ObjectId, OpenMode.ForWrite)

   Dim strOpt As New PromptStringOptions(vbCrLf & "Enter Featureline Name: ")
   strOpt.AllowSpaces = True

   Dim strRes As PromptResult = ed.GetString(strOpt)

   If strRes.Status <> PromptStatus.OK Then
      Exit Sub
   End If

   fl.Name = strRes.StringResult

   tr.Commit()
End Using

 

0 Likes
Message 3 of 3

adamg23
Participant
Participant

It appears that the issue occurs when trying to give a feature line a name that already exists in the drawing. If a feature line already has that name, the newly created line will simply have an empty string value for the name.

I appreciate you taking the time to run through an example, cheers!

0 Likes