Welcome, Guest. Please login or register.
May 16, 2012, 03:39:31 pm
Home Help Search Login Register
News: Remember to do a search before you ask a question!!!

+  TurboCAD Forums
|-+  SDK Corner
| |-+  SDK General Discussion
| | |-+  Detect Mouse Clicks
« previous next »
Pages: [1] Go Down Print
Author Topic: Detect Mouse Clicks  (Read 1249 times)
MikeCrown
Newbie
*
Posts: 11


« on: April 21, 2010, 08:08:58 am »

Hi Everyone

I'm writing a plugin that will drop drawn shapes into a drawing.

I wish to be able to prompt the user to click in the drawing, detect where the click was (x,y,z) and insert the shape where they clicked.

Is this possible  Huh

Cheers

Mike at Crowns
Logged
cwcookman
Newbie
*
Posts: 47


« Reply #1 on: April 21, 2010, 04:28:28 pm »

Yes  Grin
« Last Edit: April 21, 2010, 04:30:35 pm by cwcookman » Logged
cwcookman
Newbie
*
Posts: 47


« Reply #2 on: April 21, 2010, 04:29:59 pm »

Once I am able to get on my development machine I will see if I can find an example.

CWC
Logged
ibruethsch
Jr. Member
**
Posts: 85

Bernd


« Reply #3 on: April 22, 2010, 12:38:30 am »

Hello Mike, hello CWC
I am still using vba or vb

Dim app As Application
Dim vi, vvi As View
Dim xclick As Double
Dim yclick As Double
Dim xworld As Double
Dim yworld As Double
Dim zworld As Double
Dim xworld0 As Double
Dim yworld0 As Double
Dim zworld0 As Double
Dim xclick2 As Double
Dim yclick2 As Double
Dim xworld2 As Double
Dim yworld2 As Double
Dim zworld2 As Double



Set app = IMSIGX.Application
Set vi = app.ActiveDrawing.ActiveView
Set vvi = app.ActiveDrawing.ActiveView



vi.GetMouseClick xclick, yclick
vi.ViewToWorld xclick, yclick, 0, xworld, yworld, zworld
vi.GetMouseClick xclick2, yclick2
vi.ViewToWorld xclick2, yclick2, 0, xworld2, yworld2, zworld2

..

then you can insert the item at the desired place.

In this case the user is prompted for two clicks.
The user can use the SEKE´s (e.g. v for vertex, or i for intersection)

Best regards
Bernd
« Last Edit: April 22, 2010, 12:40:15 am by ibruethsch » Logged
cwcookman
Newbie
*
Posts: 47


« Reply #4 on: April 22, 2010, 06:09:45 pm »

Hello Bernd and Mike.

It looks like Bernd got to this before I was able to.

Attached find an Excel Spreadsheet with embedded VBA code demonstrating how to obtain the View and World Coordinates of a mouse click in TurboCad.  I have also included code that will show the world coordinates of the closest vertex to the mouse click.

The Subroutene steps are:
1- Define Variables
2- Set up a TCad View Object
3- Notify user to go to TurboCad and click the mouse
4- Get the coordinates of the mouse click
5- Get the world coordinates of the mouse click
6- Print the World Coordinates of the mouse click to the debug window
7- Pick the Graphic entities that are located at a point(xClick, yClick)in the view coordinate system
8- Print the Pick Result Count to the debug window
9- Identify the picked graphic, here is where an error will be thrown if there is nothing in the Pick Result
10- Get the closest vertex
11- Print the Coordinates of the closest vertex to the debug window
12- Error jump, Clean up objects

I do not know where your level of understand of programing is.  It is not my intention to talk down to you.  That being said, if you wish to program tools for TurboCad it is important the familiarize yourself with the TurboCad object model and demonstated in the TurboCad SDK help file.

A search of the TurboCAd help file turned up the method to Pick the Graphic objects at a point in the view coordinate system.

Syntax

expression.PickPoint(X, Y, Aperture, TopLevel, Arcs, Text, Segments, Blocks, Invisible)

expression      Required. An expression that returns a View object.
X                   Required Double. X coordinate of point in view coordinate system.
Y                   Required Double. Y coordinate of point in view coordinate system.
Aperture         Required Variant. Size of aperture in pixels.
TopLevel         Optional Variant. True if only top level Graphic object's are to be
                      picked.
Arcs                Optional Variant. True if arcs should be returned in pick.
Text                Optional Variant. True if text should be returned in pick.
Segments        Optional Variant. True if only segments should be returned in pick.
Blocks             Optional Variant. True if segments in blocks should be returned in
                       pick.
Invisible          Optional Variant. True if invisible segments can be picked.

Return Value  PickResult. The sorted results of the pick operation.

Enjoy,
CWC
Logged
Pages: [1] Go Up Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.09 seconds with 17 queries.