- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have written a program that takes USER DEFINED sketched symbols (points in this case).
The program then takes the points and creates a list of all the coordinate.
Then I get to my two problems.
1) - I want the program to put the coordinate in a custom table: I can't get this to work
2) - I want to add a specifier like "AXX" to each points. I tried with Baloons, it wouldn't work, then tried with Leader Text and it won't work
I am using Visual Studio 2019 to create my program
I followed the API Help 2021 to code my things
I searched on the internet for examples, but can't spot the difference from my code.
I linked a picture of what the drawing look like
Basically, I'm trying to add a Leader Text to a Sketched Symbol and it doesn't work
This is the code for my table
Dim oTitles() As String
ReDim oTitles(1)
oTitles(0) = "X"
oTitles(1) = "Y"
Dim oContent() As Double
ReDim oContent(oPoints.Count * 2 - 1)
Dim oColumn As Double
Dim oRow As Double
Call Orientation(oOrientationne, oPoints, oOrigin, oContent, oColumn, oRow)
Dim InsP As Point2d
InsP = _invApp.TransientGeometry.CreatePoint2d(15, 15)
Dim oCustomTable As CustomTable
oCustomTable = oSheet.CustomTables.Add("Coordonnée", InsP, oColumn, oRow, oTitles, oContent)
This is the code for my function "Orientation" I'm calling
Function Orientation(ByVal oOrientation As String, ByVal oPoints As List(Of SketchedSymbol), ByVal oOrigin As OriginIndicator, ByRef oContente() As Double, ByRef Column As Double, ByRef row As Double, Optional oOptional As Boolean = False)
Dim ThisPoint As SketchedSymbol
Dim MoinOrigine As Point2d
MoinOrigine = oOrigin.Intent.PointOnSheet
If oOrientation = "Vertical" Then
Dim i As Integer
row = oPoints.Count
Column = 2
For Each ThisPoint In oPoints
oContente(i) = ThisPoint.Position.X - MoinOrigine.X
i = i + 1
oContente(i) = ThisPoint.Position.Y - MoinOrigine.Y
i = i + 1
Next
ElseIf oOrientation = "Horizontal" Then
Dim i As Integer
row = 2
Column = oPoints.Count
For Each ThisPoint In oPoints
oContente(i) = ThisPoint.Position.X
i = i + 1
Next
For Each ThisPoint In oPoints
oContente(i) = ThisPoint.Position.Y
i = i + 1
Next
End If
End Function
End Class
And here is my code when I'm trying to create a Leader note
Dim AverageX As Double
Dim AverageY As Double
AverageX = oView.Width / 2
AverageY = oView.Height / 2
Dim MoinOrigine As Point2d
MoinOrigine = oOrigin.Intent.PointOnSheet
Dim OffX As Double
Dim OffY As Double
Dim b As Integer
For Each ThisPoint In oPoints
Dim oLeaderPoints As ObjectCollection
oLeaderPoints = _invApp.TransientObjects.CreateObjectCollection
b = b + 1
If ThisPoint.Position.X - MoinOrigine.X >= AverageX Then
OffX = oView.Width / 15
ElseIf ThisPoint.Position.X - MoinOrigine.X < AverageX Then
OffX = -oView.Width / 15
End If
If ThisPoint.Position.Y - MoinOrigine.Y >= AverageY Then
OffY = -oView.Height / 20
ElseIf ThisPoint.Position.Y - MoinOrigine.Y < AverageY Then
OffY = oView.Height / 20
End If
oLeaderPoints.Add(_invApp.TransientGeometry.CreatePoint2d(60, 45))
oLeaderPoints.Add(ThisPoint.Position)
Dim GeomIntentText As GeometryIntent =
oSheet.CreateGeometryIntent(ThisPoint, ThisPoint.Position)
oLeaderPoints.Add(GeomIntentText)
Dim f As String
f = String.Concat("A", b.ToString)
Dim OLeaderNote As LeaderNote =
oSheet.DrawingNotes.LeaderNotes.Add(oLeaderPoints, f)<FAILS HERE
Dim oFirstNode As LeaderNode =
OLeaderNote.Leader.RootNode.ChildNodes.Item(1)
Dim oSeconNode As LeaderNode =
oFirstNode.ChildNodes.Item(1)
oFirstNode.InsertNode(oSeconNode, _invApp.TransientGeometry.CreatePoint2d(ThisPoint.Position.X, ThisPoint.Position.Y))
Next
And if this code isn't enough I already have it on GitHub so I can let people at my job change it or propose new feature even when I'm gone - GitHub
You can import it and try things with it
File I use for testing linked with this post
Thank you for your help!
Solved! Go to Solution.