Author Topic: STRUCTURE PROFILE LABEL  (Read 3027 times)

0 Members and 1 Guest are viewing this topic.

JCK_Hack

  • Mosquito
  • Posts: 2
STRUCTURE PROFILE LABEL
« on: November 10, 2023, 08:40:13 AM »
Does anyone have guidance on manipulating Structure or Pipe Profile Label locations?

Code - vb.net: [Select]
  1.     Dim label As StructureProfileLabel = tr.GetObject(labelId, OpenMode.ForWrite)
  2.     If labelId <> firstLabelId Then
  3.         label.Pinned = False
  4.         label.ResetLocation()
  5.         'Totally lost
  6.         label.GetGraphicsMarkersAtSubentityPathIntPtr(label.MoveGripPointsAtSubentityPaths()
  7.         'Totally lost
  8.     End If
  9. [code=vbnet]
  10.  
  11.  

JCK_Hack

  • Mosquito
  • Posts: 2
STRUCTURE PROFILE LABEL
« Reply #1 on: November 14, 2023, 11:10:21 AM »
It makes me sad when I find examples--from almost a decade ago--which show people being way smarter and better at coding than I'll ever be!  And solving issues and problems I'm just now working on. 

It makes me even more sad when I find the example and can't get it to work...(I'm trying to understand and get running the AutoCAD2012NewAPIsSamples.DevDaysGripMenusSample app.)

I keep getting a fatal error when I run the below code. MsgBox("GripEx 1") works and then fatal error.

Even if I can fix this error, can someone please give me more insight into the Grips, Snaps, and GeomIds which the command .GetGripPoints request in more detail?  I'm just not getting the concepts.  My ultimate goal is to better understand StructureProfileLabels and PipeProfileLabels to adjust them according to the previous example above.  Any help or guidance would be appreciated. 

Code - vb.net: [Select]
  1. 'Inherits GripOverrule
  2. 'From AutoCAD2012NewAPIsSamples
  3.         <CommandMethod("GripEx")>
  4.         Public Sub GripExample()
  5.             Dim doc As Document = Core.Application.DocumentManager.MdiActiveDocument
  6.             Dim ed As Editor = doc.Editor
  7.             Dim db As Database = doc.Database
  8.             Dim dist As Double = Core.Application.GetSystemVariable("USERR3")
  9.             Dim tv(0) As TypedValue
  10.             tv.SetValue(New TypedValue(DxfCode.Start, "AECC_STRUCTURE_PROFILE_LABEL"), 0)
  11.             Dim MyFilter As New SelectionFilter(tv)
  12.             Dim Mygrips As Point3dCollection
  13.             Dim Mysnaps As IntegerCollection
  14.             Dim MygeomIds As IntegerCollection
  15.             Try
  16.                 ' Prompt the user to select the first label.
  17.                 Dim STRLabelRes As PromptEntityResult = ed.GetEntity("Select the first surface label: " & vbCrLf)
  18.                 If STRLabelRes.Status <> PromptStatus.OK Then
  19.                     Return
  20.                 End If
  21.                 Dim STRLabelId As ObjectId = STRLabelRes.ObjectId
  22.  
  23.                 Using tr As Transaction = db.TransactionManager.StartTransaction()
  24.                     Dim STRLabel As Autodesk.Civil.DatabaseServices.StructureProfileLabel = tr.GetObject(STRLabelId, OpenMode.ForWrite)
  25.                     ' Initialize the collections
  26.                     Mygrips = New Point3dCollection()
  27.                     Mysnaps = New IntegerCollection()
  28.                     MygeomIds = New IntegerCollection()
  29.                   MsgBox("GripEx 1")
  30.                     MyBase.GetGripPoints(STRLabel, Mygrips, Mysnaps, MygeomIds)
  31.                   MsgBox("GripEx 2")
  32.                     MyBase.MoveGripPointsAt(STRLabel, Mysnaps, New Vector3d(4, 4, 4))
  33.                    MsgBox("GripEx 3")
  34.                     tr.Commit()
  35.                 End Using
  36.             Catch
  37.  
  38.             End Try
  39.         End Sub

twdotson

  • Mosquito
  • Posts: 17
Re: STRUCTURE PROFILE LABEL
« Reply #2 on: November 14, 2023, 04:57:43 PM »
I also encountered a fatal error when I tried to use MoveGripPointsAt in an attempt to get around the lack of an API on FeatureLines.

https://forums.autodesk.com/t5/civil-3d-customization/civil3d-2016-net-api-comprehensive-featureline-functionality/m-p/5565183/highlight/true#M10178