Message 1 of 4

Not applicable
08-17-2017
04:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
'm trying to place a textbox in a drawingview sketch on the mouseposition.
The problem is that the position of the textbox seems to be at the center of the drawingview and not on the mouseposition.
What's wrong?
VB.Net Code:
Private Sub mobjDrawNumbersFactoryCmd_OnExecute(Context As NameValueMap) Handles mobjDrawNumbersFactoryCmd.OnExecute StartAgain: 'get startnumber Dim answ As String = InputBox("Startnumber: ",, "1") Dim number As Integer Try number = CInt(answ) Catch ex As Exception m_inventorApplication.CommandManager.PromptMessage(answ & " is not a number!", MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation, "Waarschuwing!", MsgBoxResult.Ok) GoTo StartAgain End Try 'get drawingdocument Dim oDrawDoc As Inventor.DrawingDocument = m_inventorApplication.ActiveDocument 'get active sheet Dim oSheet As Inventor.Sheet = oDrawDoc.ActiveSheet Dim insertionpoint3D As Inventor.Point = Nothing Dim oSketch As Inventor.Sketch = Nothing Dim selectedDrawingView As DrawingView = Nothing 'check in which drawingview the numbers got to be placed For Each drawingView As DrawingView In oSheet.DrawingViews Dim pointCenter As Point2d = drawingView.Position Dim point1 As Point2d = m_inventorApplication.TransientGeometry.CreatePoint2d((pointCenter.X - drawingView.Width / 2), (pointCenter.Y - drawingView.Height / 2)) Dim point2 As Point2d = m_inventorApplication.TransientGeometry.CreatePoint2d((point1.X + drawingView.Width), (point1.Y + drawingView.Height)) 'get insertionpoint first number Dim oSelect As New clsSelect insertionpoint3D = oSelect.Pick(Inventor.SelectionFilterEnum.kAllPointEntities, "Place number: 1") If insertionpoint3D.X >= point1.X _ And insertionpoint3D.Y >= point1.Y _ And insertionpoint3D.X <= point2.X _ And insertionpoint3D.Y <= point2.Y Then selectedDrawingView = drawingView Exit For End If Next 'check if there is already a sketch with this name Dim sketchNumber As Int32 = 1 Dim sketchName As String = "Numbers-" & sketchNumber If selectedDrawingView Is Nothing Then selectedDrawingView = oSheet.DrawingViews(1) For Each oSketch In selectedDrawingView.Sketches If oSketch.Name = sketchName Then sketchNumber = sketchNumber + 1 sketchName = "Numbers-" & sketchNumber End If Next 'add a new sketch in drawingview oSketch = selectedDrawingView.Sketches.Add() oSketch.Name = sketchName oSketch.Edit() Dim isStopped As Boolean 'define a new textbox Dim aTextbox As Inventor.TextBox Do While isStopped = False m_inventorApplication.UserInterfaceManager.DoEvents() 'check if user presses ESC Try 'define insertionpoint 2D Dim insertionpoint2D As Inventor.Point2d = m_inventorApplication.TransientGeometry.CreatePoint2d(insertionpoint3D.X, insertionpoint3D.Y) 'draw textbox aTextbox = oSketch.TextBoxes.AddFitted(insertionpoint2D, number) Catch ex As Exception isStopped = True End Try number = number + 1 'get next insertionpoint Dim oSelect As New clsSelect insertionpoint3D = oSelect.Pick(Inventor.SelectionFilterEnum.kAllPointEntities, "Place number: " & number) Loop 'close sketchedit oSketch.ExitEdit() End Sub
Solved! Go to Solution.