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.
'Inherits GripOverrule
'From AutoCAD2012NewAPIsSamples
<CommandMethod("GripEx")>
Public Sub GripExample()
Dim doc As Document = Core.Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim db As Database = doc.Database
Dim dist As Double = Core.Application.GetSystemVariable("USERR3")
Dim tv(0) As TypedValue
tv.SetValue(New TypedValue(DxfCode.Start, "AECC_STRUCTURE_PROFILE_LABEL"), 0)
Dim MyFilter As New SelectionFilter(tv)
Dim Mygrips As Point3dCollection
Dim Mysnaps As IntegerCollection
Dim MygeomIds As IntegerCollection
Try
' Prompt the user to select the first label.
Dim STRLabelRes As PromptEntityResult = ed.GetEntity("Select the first surface label: " & vbCrLf)
If STRLabelRes.Status <> PromptStatus.OK Then
Return
End If
Dim STRLabelId As ObjectId = STRLabelRes.ObjectId
Using tr As Transaction = db.TransactionManager.StartTransaction()
Dim STRLabel As Autodesk.Civil.DatabaseServices.StructureProfileLabel = tr.GetObject(STRLabelId, OpenMode.ForWrite)
' Initialize the collections
Mygrips = New Point3dCollection()
Mysnaps = New IntegerCollection()
MygeomIds = New IntegerCollection()
MyBase.GetGripPoints(STRLabel, Mygrips, Mysnaps, MygeomIds)
MyBase.MoveGripPointsAt(STRLabel, Mysnaps, New Vector3d(4, 4, 4))
tr.Commit()
End Using
Catch
End Try
End Sub