Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Label Method SetReferenceTextTarget

6 REPLIES 6
Reply
Message 1 of 7
Civil3DReminders_com
335 Views, 6 Replies

Label Method SetReferenceTextTarget

Civil 3D 2014, Pre SP2

 

Does this method work for surface references? I can get it to work for all of the other types of reference text objects, but the Surface throws an error "The reference object is not match with the text component.". All of the objects utilize the same code block and I've made sure the objectId of the reference object does belong to a surface.

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
6 REPLIES 6
Message 2 of 7

This error also occurs in 2015.

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
Message 3 of 7

Could you please provide a sample project and test drawing so that we can reproduce this issue? 

 

 



Daniel Du
Developer Technical Services
Autodesk Developer Network

Message 4 of 7

Here is a link to a code sample: http://blog.civil3dreminders.com/2014/09/set-reference-text.html

 

Attached is a sample file to test the code. Run the command, select the surface, select the label, and then find the easter egg in the code! If the developer's are lucky then the easter egg won't show up.

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
Message 5 of 7

Has anyone resolved this issue?  I'm coming across the same issue.

Here's a sample in VB.net

 

        Dim labAtt As String = "RefAlign"
        Dim LabelObj As C3DData.Label = DirectCast(TransMgr.GetObject(LabelID, OpenMode.ForWrite, True), C3DData.Label)
        Dim MyComponents As ObjectIdCollection = LabelObj.GetTextComponentIds()
        Dim ComponentID As ObjectId = Nothing
        For x As Int16 = 0 To MyComponents.Count - 1
            Dim GenericObj As Object = MyComponents(x).GetObject(OpenMode.ForRead)
            Dim CompType As String = GenericObj.GetType().Name
            If CompType = "LabelStyleReferenceTextComponent" Then
                Dim tmpTxtComp As C3DData.Styles.LabelStyleReferenceTextComponent =
                                  MyComponents(x).GetObject(OpenMode.ForRead)
                If tmpTxtComp.Name = labAtt Then
                    ComponentID = tmpTxtComp.ObjectId
                End If
            End If
        Next
        If ComponentID <> Nothing Then
            'Validate that Label type and Target object type are same type
            If ValidateTarget(ComponentID, TargetID) Then
' This works for everything except Surface components LabelObj.SetReferenceTextTarget(ComponentID, TargetID) End If End If
Genius unexerted is no more genius than a bushel of acorns is a forest of oaks. ~ H. Ward Beecher
Message 6 of 7

API work appears to have been put at the bottom of the to do bucket. Most, if not all, of the Civil 3D API people got moved over to Infraworks. I haven't tested it recently, but I doubt it's been resolved.

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
Message 7 of 7

Maybe it has something to do with the Label component's ReferenceTextObjectType not being equal to the target objects GetType().Name?

They are the same for "Alignment", "CogoPoint", and "Parcel".

 

 

But with surface references, the ReferenceTextObjectType is only "Surface" which doesn't correlate to a Civil3D object type.

 

There is only "TinSurface", "GridSurface", "VolumeSurface".  The internal method SetReferenceTextTarget probably compares these and throws the error...

System.ArgumentException: The reference object is not match with the text component.

 

 

Just speculating... in case someone from Autodesk actually reads this.

Genius unexerted is no more genius than a bushel of acorns is a forest of oaks. ~ H. Ward Beecher

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report