InteractionEvents and SelectEvents: Select midpoint in sketch

InteractionEvents and SelectEvents: Select midpoint in sketch

ACEDeSmedt
Advocate Advocate
875 Views
6 Replies
Message 1 of 7

InteractionEvents and SelectEvents: Select midpoint in sketch

ACEDeSmedt
Advocate
Advocate
This is about the Select Event.

I'm writing a macro to add an new constrain in the sketch environment. It is a combination of the Vertical and the horizontal constrain.

First the user can select 2 points (just like the vertical and horizontal constrain commando)
Than the macro calculate, based on the angle between the 2 points, witch constraint to use
and the apply the right horizontal or vertical constraint.
With this macro you cant miss with aligning 2 points using vertical or horizontal constraint.

The problem is in the first step. I want the selection filter of the macro exactly the same as the selection filter of the constraint commando. Problem now is that I cant select midpoints of a line (the green dot that appears when you hover over the midpoint) Anyone an idea ?

for the selection I'm using the InteractionEvents with SelectEvents
(Almost the Exact example in the programming help of inventor 2009)

[...]

' Set the filter using the value passed in.
oSelectEvents.AddSelectionFilter kSketchPointFilter

' Start the InteractionEvents object.
oInteractEvents.Start

' Loop until a selection is made.
Do While bStillSelecting
DoEvents
Loop

[...]

Ask if someone is interested in more information

kind regards
Klaas De Smedt
=================================
If this is the solution, push the solution button 😉 (and maybe some kudos)
Autodesk Product Design Suit - Ultimate edition (Subscription)
0 Likes
876 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
Use MouseEvents for this. Set the MouseEvents.PointInferenceEnabled property
to True and you should get the selection beahvior you want. When you receive
the OnMouseClick event, query the MouseEvents.PointInferences property to
get the selected objects.

Sanjay-
0 Likes
Message 3 of 7

ACEDeSmedt
Advocate
Advocate
OK, now I get the green dot like in the Vertical constraint commando but is there a way to hide/disable the yellow dot following the cursor ?

Also I disabled MouseMove To increase Performance 😉
{code}oMouseEvents.MouseMoveEnabled = False{code}

And now i only can select points, is there a way to select points and lines ?
(just like the Vert/Horz Constraint commando)
Or Do I have to work with the SelectEventsObject and use the Graphics Overlay Object to create a preview of Midpoint of a line ?

Kind regards
Klaas De Smedt Edited by: ACEDeSmedt on Aug 25, 2009 4:52 PM
=================================
If this is the solution, push the solution button 😉 (and maybe some kudos)
Autodesk Product Design Suit - Ultimate edition (Subscription)
0 Likes
Message 4 of 7

Anonymous
Not applicable
Once you are in the point selection mode in MouseEvents, you can right click
and choose the "MidPoint" option. This will put you in midpoint selection
mode. So this is something that the user must do when in selection mode. If
you want to put the user in that mode, you can try the following:

Dim oDef As ControlDefinition
Set oDef =
ThisApplication.CommandManager.ControlDefinitions("GetPointMidpoint")

oDef.Execute

Sanjay-
0 Likes
Message 5 of 7

ACEDeSmedt
Advocate
Advocate
Works good, but then you are only in a 'select midpoint enviroment'
(thanks by the way for all your help, Sanjay)

I think the SelectEventObject is the solution

with the combination of the OnPreselectMouseMove event I can check if a sketchline is selected and how close the user is to the midpoint of the line. When in a close range, i need to preselect the midpoint instead of the line.

I'm stuck on the last step, stop preselecting the line and preselect the midpoint.

I really want to create the same selection enviroment as the vertical and horizontal constraint commando


kind regards,
Klaas De Smedt
=================================
If this is the solution, push the solution button 😉 (and maybe some kudos)
Autodesk Product Design Suit - Ultimate edition (Subscription)
0 Likes
Message 6 of 7

ACEDeSmedt
Advocate
Advocate
Good, now I'm almost there,

To preselct the midpoint i was thinking of using the overlay graphics.

Enyone know how to draw a green dot/sphere (shaded) to display?

I think it is something with the client graphincs, addnode pointnode renderstyle something like that

Klaas De Smedt
=================================
If this is the solution, push the solution button 😉 (and maybe some kudos)
Autodesk Product Design Suit - Ultimate edition (Subscription)
0 Likes
Message 7 of 7

Anonymous
Not applicable
Sample below to create a sphere using overlay client graphics. Note that
since you need to show this in the context of the sketch, you'll need to
provide the sphere center obtained by correctly transforming the sketch
point to model space point (use PlanarSketch.SketchToModelSpace method).

Sanjay-


Private oIE As InteractionEvents

Public Sub DrawOverlayGraphics()

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Set oIE = ThisApplication.CommandManager.CreateInteractionEvents
oIE.Start

Dim oIG As InteractionGraphics
Set oIG = oIE.InteractionGraphics

On Error Resume Next
Dim oDataSets As GraphicsDataSets
Set oDataSets = oIG.GraphicsDataSets

' Set a reference to the transient geometry object for use later.
Dim oTransGeom As TransientGeometry
Set oTransGeom = ThisApplication.TransientGeometry

' Create the ClientGraphics object.
Dim oClientGraphics As ClientGraphics
Set oClientGraphics = oIG.OverlayClientGraphics

' Create a new graphics node within the client graphics objects.
Dim oSurfacesNode As GraphicsNode
Set oSurfacesNode = oClientGraphics.AddNode(1)

Dim oTransientBRep As TransientBRep
Set oTransientBRep = ThisApplication.TransientBRep

' Create a point representing the center of the sphere
Dim oCenter As Point
Set oCenter = oTransGeom.CreatePoint(2, 2, 2)

' Create a transient sphere body
Dim oBody As SurfaceBody
Set oBody = oTransientBRep.CreateSolidSphere(oCenter, 0.1)

' Create client graphics based on the transient body
Dim oSurfaceGraphics As SurfaceGraphics
Set oSurfaceGraphics = oSurfacesNode.AddSurfaceGraphics(oBody)
oSurfaceGraphics.Color = ThisApplication.TransientObjects.CreateColor(0,
255, 0)
'Call oSurfaceGraphics.SetTransformBehavior(oCenter, kPixelScaling)
' Update the view.
oIG.UpdateOverlayGraphics ThisApplication.ActiveView

End Sub
0 Likes