- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I am trying to create i kind of autoballoon function.
I found that it is pretty hard to move the leaderpoitn that has the arrow on it.
but now i want to use the location where the balloon leader is starting to relocate the balloons.
The startpoint of the leader is created using the 'creategeometryintent' function.
for this function i use a curve as input, and the output is a point2D.
now the problem is that when i want to read the coordinates point, but when i put this in a messagebox i get an error.
also when i create a paramter as a double and write the coordinate to this, it wont work.
can someone explain why i cannot read the coordinates of this point?
this code can be run from any drawing with at least 4 views in it, so feel free to try.
Dim oDrawing As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDrawing.ActiveSheet
Dim oView As DrawingView = oSheet.DrawingViews.Item(4)
Dim oReferDoc As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oAssyDef As AssemblyComponentDefinition = oReferDoc.ComponentDefinition
Dim Occ As ComponentOccurrence
Dim oCurve As DrawingCurve
For Each Occ In oAssyDef.Occurrences
If oView.DrawingCurves(Occ).Count > 0 Then
Dim oCurves As DrawingCurvesEnumerator = oView.DrawingCurves(Occ)
oCurve = oCurves.Item(1)
MsgBox("Curves found")
Else
GoTo Volgende
End If
'Dim oDrawingCurve As DrawingCurve = oActiveSheet.DrawingViews.Item(4).DrawingCurves.Item(i)
Dim oMidpoint As Point2d
Try
If oCurve.CurveType <> 5124 Then
oMidpoint = oCurve.MidPoint
Else
oMidpoint = oCurve.CenterPoint
End If
Catch
End Try
' Set a reference to the TransientGeometry object.
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oLeaderPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
' Create a couple of leader points.
Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidpoint.X + 10, oMidpoint.Y + 10))
Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidpoint.X + 10, oMidpoint.Y + 5))
' Add the GeometryIntent to the leader points collection.
' This is the geometry that the balloon will attach to.
Dim oGeometryIntent As GeometryIntent = oSheet.CreateGeometryIntent(oCurve)
Dim xcord As Double = oGeometryIntent.PointOnSheet.X
MsgBox(xcord)
' MsgBox(oGeometryIntent.PointOnSheet.X & " " & oGeometryIntent.PointOnSheet.Y)
Call oLeaderPoints.Add(oGeometryIntent)
' Set a reference to the parent drawing view of the selected curve
Dim oDrawingView As DrawingView = oCurve.Parent
' Set a reference to the referenced model document
Dim oModelDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
' Check if a partslist or a balloon has already been created for this model
Dim IsDrawingBOMDefined As Boolean
IsDrawingBOMDefined = oDrawing.DrawingBOMs.IsDrawingBOMDefined(oModelDoc.FullFileName)
Dim oBalloon As Balloon
If IsDrawingBOMDefined Then
' Just create the balloon with the leader points
' All other arguments can be ignored
oBalloon = oDrawing.ActiveSheet.Balloons.Add(oLeaderPoints)
Else
' First check if the 'structured' BOM view has been enabled in the model
' Set a reference to the model's BOM object
Dim oBOM As BOM = oModelDoc.ComponentDefinition.BOM
If oBOM.StructuredViewEnabled Then
' Level needs to be specified
' Numbering options have already been defined
' Get the Level ('All levels' or 'First level only')
' from the model BOM view - must use the same here
Dim Level As PartsListLevelEnum
If oBOM.StructuredViewFirstLevelOnly Then
Level = kStructured
Else
Level = kStructuredAllLevels
End If
oBalloon = oSheet.Balloons.Add(oLeaderPoints, , Level)
Else
Dim oNumberingScheme As NameValueMap= ThisApplication.TransientObjects.CreateNameValueMap
oNumberingScheme.Add ("Delimiter", ",")
oBalloon = oSheet.Balloons.Add(oLeaderPoints, , kStructuredAllLevels, oNumberingScheme)
End If
End If
Volgende:
Next
Dim bloon As Balloon
Dim compare As String = ""
For Each bloon In oSheet.Balloons
If compare = bloon.BalloonValueSets.Item(1).Value Then
bloon.Delete
Else
compare = bloon.BalloonValueSets.Item(1).Value
End If
Next
Solved! Go to Solution.