Get Current Cursor Position

Good morning guys -

How would I go about getting the current position of the SolidWorkscursor? I have a macro that I put together that inserts text at aspecific location. How could I change my code to read the locationof the cursor, and input the text at that location?


Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim feature As Object
Dim NoteText As String
Dim Annotation As Object
Dim TextFormat As Object
Dim Note1 As Object
Private Sub Create_Click()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
'boolstatus = Part.ActivateView("Drawing View1")
NoteText = UCase(" " & Form1.Note.Text & " ")
Set Note1 = Part.InsertNote(NoteText)
Note1.Angle = 0
boolstatus = Note1.SetBalloon(8, 0)
Set Annotation = Note1.GetAnnotation()
longstatus = Annotation.SetLeader2(False, 0, True, False, False,False)
'''''''''''''Text insertion point defined here
boolstatus = Annotation.SetPosition(0.06533629508197,0.1862069836066, 0)
boolstatus = Annotation.SetTextFormat(0, True, TextFormat)
Part.ClearSelection2 True
Part.WindowRedraw
Form1.Note.Text = ""
Set SelMgr = Nothing
Set Part = Nothing
Set swApp = Nothing
Form1.Hide
End Sub

Thanks!SolidworksApi macros
Comments 2
SF
SF 2007-05-08
Hey Tony,

I did a quick search in the SolidWorks and Add-Ins API help
and i came up with this SelectData::X ,

Description

This property gets orsetsthe X coordinate for the selection point.


I I haven't tried it yet to be honest so i don't knowthespecifics. I will play a bit around with
it later on and let you know if i get any results. Irecommend youdo the same

Regards,

--Stav.




SF
SF 2007-05-08
Hello Tony,

Below is a snippet of a script I wrote to insert a note ataspecific x and y location on each sheet of a drawing:

For currentsheet = 0 To swDraw.GetSheetCount-1

swDraw.ActivateSheet (Names(currentsheet))

Set swSheet = swDraw.GetCurrentSheet

vSheetProps=translator.makeReadable(swSheet.GetProperties())

 

Select Case vSheetProps(0)

    Case 0

       swCharHeight = 0.007 /1.5

       swXpos = 0.1

    Case 1

       swCharHeight = 0.007 /1.5

       swXpos = 0.1

    Case 2

       swCharHeight = 0.007

       swXpos = 0.17

    Case 3

       swCharHeight = 1.33 *0.007

       swXpos = 0.25

    Case 4

       swCharHeight = 1.5 *0.007

       swXpos = 0.4

    Case 5

   

EndSelect                        

 

'Set Note =Part.InsertNote("PRELIMINARY" &Chr(13) & Chr(10)& Date)

Set Note =Part.InsertNote("PRELIMINARY")

 

If Not Note Is Nothing Then

   Note.Angle = 0

   Note.SetTextJustification (2)

   boolstatus =Note.SetBalloon(0,0)

   Set Annotation=Note.GetAnnotation()

   Set swTextFormat=Annotation.GetTextFormat(0)

   swTextFormat.TypeFaceName ="ArialBlack"

   swTextFormat.CharHeight=swCharHeight

  

  

   If Not Annotation IsNothingThen

      longstatus=Annotation.SetLeader2(False, 0, True, True, False, False)

      boolstatus=Annotation.SetPosition(swXpos, 0.037, 0)

      boolstatus=Annotation.SetTextFormat(0, False, swTextFormat)

 

     Annotation.Color= 12632256

   End If

End If

Part.ClearSelection2 True

Part.WindowRedraw

Next