- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
There are a few threads on this but none address my issue directly.
I'm able to attach sketched symbols to dimensions with a leader which allows the sketch symbol to follow the dimension. However, I can't seem to do this with chamfer notes and textual notes.
The only way I can see that they differ from dimensions is that the "RangeBox" on the dimensional objects is nested within the "Text" subset (ie for the dimension I would pass oDim.Text.Rangebox.MaxPoint whereas for the note I have to pass oDim .Rangebox.MaxPoint)
I assume the problem has something to do with the creation of the GeometryIntent, as this is the only real difference that would matter. But I'm not sure how else to direct the leader intent to the note.
The hangup is happening on the last step of the addleader command. What I have currently is:
Private Sub AddBalloon(ByVal CurrRow As Integer, ByVal Insert As Boolean) Dim oDoc As DrawingDocument = _invApp.ActiveDocument Dim oInteraction As InteractionEvents = _invApp.CommandManager.CreateInteractionEvents oInteraction.StatusBarText = "Select a dimension" oSelect = oInteraction.SelectEvents oSelect.AddSelectionFilter(SelectionFilterEnum.kDrawingDimensionFilter) oSelect.SingleSelectEnabled = True oInteraction.Start() Dim oSheetSettings As SheetSettings = oDoc.SheetSettings Dim SelectedFeature = _invApp.CommandManager.Pick(SelectionFilterEnum.kDrawingNoteFilter, "") '.kAllEntitiesFilter, "Select something") If SelectedFeature Is Nothing Then Exit Sub Dim RefKeyValue() As Byte = New Byte() {} Call SelectedFeature.GetReferenceKey(RefKeyValue) Dim RefKey As String = _invApp.ActiveDocument.ReferenceKeyManager.KeyToString(RefKeyValue) Note(SelectedFeature, RefKey, Balloon) End Sub
Public Sub Note(oDim As DrawingNote, RefKey As String, Balloon As Integer) InsertSketchedSymbolSample(oDim, oDim.RangeBox.MaxPoint, oDim.RangeBox.MinPoint, RefKey, Balloon) End Sub
Private Sub InsertSketchedSymbolSample(oDim As Object, ByRef MaxP As Point2d, ByRef MinP As Point2d, ByRef Values As String, ByRef Balloon As Integer) Dim oDrawDoc As DrawingDocument oDrawDoc = _invApp.ActiveDocument ' Obtain a sketched symbol definition. Dim oSketchedSymbolDef As SketchedSymbolDefinition = Nothing For i = 1 To oDrawDoc.SketchedSymbolDefinitions.Count If oDrawDoc.SketchedSymbolDefinitions.Item(i).Name = "Insp" Then oSketchedSymbolDef = oDrawDoc.SketchedSymbolDefinitions.Item(i) Exit For End If Next If oSketchedSymbolDef Is Nothing Then CreateSketchedSymbolDefinition() For i = 1 To oDrawDoc.SketchedSymbolDefinitions.Count If oDrawDoc.SketchedSymbolDefinitions.Item(i).Name = "Insp" Then oSketchedSymbolDef = oDrawDoc.SketchedSymbolDefinitions.Item(i) Exit For End If Next End If Dim oSheet As Sheet oSheet = oDrawDoc.ActiveSheet Dim sPromptStrings() As String = {Balloon, Values} ' Create sketched symbol Dim oTG As TransientGeometry oTG = _invApp.TransientGeometry Dim oPoint As Point2d oPoint = oTG.CreatePoint2d(MinP.X - (0.1), MaxP.Y + (0.1)) Dim oSketchedSymbol As SketchedSymbol Dim oGI As GeometryIntent oGI = oSheet.CreateGeometryIntent(oDim, oPoint) Dim oCol As ObjectCollection oCol = _invApp.TransientObjects.CreateObjectCollection oCol.Add(oPoint) oCol.Add(oGI) oSketchedSymbol = oSheet.SketchedSymbols.Add(oSketchedSymbolDef, oPoint, 0, 1, sPromptStrings) ' THIS IS WHERE THE ERROR OCURRS'
oSketchedSymbol.Leader.AddLeader(oCol) oSketchedSymbol.LeaderVisible = False End Sub Private Sub CreateSketchedSymbolDefinition() ' Set a reference to the drawing document. ' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument oDrawDoc = _invApp.ActiveDocument ' Create the new sketched symbol definition. Dim oSketchedSymbolDef As SketchedSymbolDefinition oSketchedSymbolDef = oDrawDoc.SketchedSymbolDefinitions.Add("Insp") ' Open the sketched symbol definition's sketch for edit. This is done by calling the Edit ' method of the SketchedSymbolDefinition to obtain a DrawingSketch. This actually creates ' a copy of the sketched symbol definition's and opens it for edit. Dim oSketch As DrawingSketch = Nothing Call oSketchedSymbolDef.Edit(oSketch) Dim oTG As TransientGeometry oTG = _invApp.TransientGeometry Dim oInsertionPoint As Point2d = (oTG.CreatePoint2d(0, 0)) Dim oSketchCircle As SketchCircle oSketchCircle = oSketch.SketchCircles.AddByCenterRadius(oTG.CreatePoint2d(0, 0), (0.1333)) Dim oSheetSettings As SheetSettings = oDrawDoc.SheetSettings Dim oColor As Color = _invApp.TransientObjects.CreateColor(oSheetSettings.SheetColor.Red, oSheetSettings.SheetColor.Green, oSheetSettings.SheetColor.Blue, 0) ' Add a prompted text field at the center of the sketch circle. Dim sText As String sText = "<StyleOverride FontSize='" & 0.2 & "'>" & "<Prompt>Number</Prompt>" & "</StyleOverride>" Dim oTextBox As Inventor.TextBox Dim ValueText As String = "<StyleOverride FontSize='" & 0.0001 & "'>" & "<Prompt>Value</Prompt>" & "</StyleOverride>" oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(0, 0), sText) oTextBox.VerticalJustification = VerticalTextAlignmentEnum.kAlignTextMiddle oTextBox.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextCenter oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(0, 0), ValueText) oTextBox.Color = oColor ' oTextBox.FormattedText = "<StyleOverride FontSize='0.08'></StyleOverride>" Call oSketchedSymbolDef.ExitEdit(True) End Sub
Solved! Go to Solution.