Part Sketch Dimensioning Preview / Hang on cursor

Part Sketch Dimensioning Preview / Hang on cursor

bradeneuropeArthur
Mentor Mentor
334 Views
3 Replies
Message 1 of 4

Part Sketch Dimensioning Preview / Hang on cursor

bradeneuropeArthur
Mentor
Mentor

How do I create a preview of a sketch-dimension created.

the dimension should follow the cursor before the place is picked on the screen.

 

This is my code so far but the dimension placement is not following the cursor:

 

Class ThisRule
Dim oInteraction As InteractionEvents
Dim oMouse As MouseEvents
Dim pm As Point2d
Dim sp1 As SketchPoint
Dim sp2 As SketchPoint

Public Sub main
oInteraction = ThisApplication.CommandManager.CreateInteractionEvents
oMouse = oInteraction.MouseEvents

AddHandler oMouse.OnMouseClick, AddressOf oMouse_OnMouseDown 

Dim cmd As CommandManager = ThisApplication.CommandManager
sp1 = cmd.Pick(Inventor.SelectionFilterEnum.kSketchPointFilter, "Point 1")
sp2 = cmd.Pick(Inventor.SelectionFilterEnum.kSketchPointFilter, "Point 2")

oInteraction.Start

End Sub

Sub oMouse_OnMouseDown(Button As MouseButtonEnum, ShiftKeys As ShiftStateEnum, ModelPosition As Point, ViewPosition As Point2d, View As Inventor.View)

  Dim p2d As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(ModelPosition.X,ModelPosition.Y)

Dim p As PartDocument = ThisDoc.Document
Dim pc As PartComponentDefinition = p.ComponentDefinition
Dim psk As PlanarSketch = pc.Sketches.Item(1)
Try
	Dim pskd1 As DimensionConstraint = psk.DimensionConstraints.AddTwoPointDistance(sp1, sp2, Inventor.DimensionOrientationEnum.kAlignedDim, p2d, False)
	
	Catch
	Dim pskd1 As DimensionConstraint = psk.DimensionConstraints.AddTwoPointDistance(sp1, sp2, Inventor.DimensionOrientationEnum.kAlignedDim, p2d, True)
	End Try

oInteraction.Stop

End Sub
End Class

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Accepted solutions (1)
335 Views
3 Replies
Replies (3)
Message 2 of 4

C_Haines_ENG
Collaborator
Collaborator
Accepted solution

I believe you will want to use MouseEvents.OnMouseMove for that application. The ViewPosition variable will give you the coordinates of the mouse so you can continuously update the location of the text. 

 

However, I assume this will have LARGE performance impacts. Worth testing.

Message 3 of 4

Michael.Navara
Advisor
Advisor

The performance impact is not so significant. You can try it in this two samples.

0 Likes
Message 4 of 4

C_Haines_ENG
Collaborator
Collaborator

Wow that actually works great! Will have to use in the future. 

0 Likes