How to hang something up on my mouse cursor

bradeneuropeArthur
Mentor
Mentor

How to hang something up on my mouse cursor

bradeneuropeArthur
Mentor
Mentor

How to hang something on my mouse cursor so that it will move with the cursor. I want to insert a sketchblok and move it with my cursor.

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

0 Likes
Reply
213 Views
3 Replies
Replies (3)

yuzeaa
Advocate
Advocate
Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
Dim oSketchBlockDef = oPartDoc.ComponentDefinition.SketchBlockDefinitions.Item("My Block Def")
oPartDoc.SelectSet.Select(oSketchBlockDef)
ThisApplication.CommandManager.ControlDefinitions.Item("SketchRigidSetPlaceInstanceCmd").Execute

bradeneuropeArthur
Mentor
Mentor

I there a way to do this all with some piece of code without using the CommandManager?

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

0 Likes

JelteDeJong
Mentor
Mentor

This rule will attach the first sketch symbol on the active sheet. It will stop moving when you click somewhere

Public Class ThisRule
    Public Sub main()

        Dim doc As DrawingDocument = ThisDoc.Document
        Dim sheet As Sheet = doc.ActiveSheet
        Dim symbol As SketchedSymbol = sheet.SketchedSymbols.Item(1)

        Dim s As New Selector(ThisApplication)
        s.Pick(symbol)
    End Sub
End Class

Public Class Selector

    Private WithEvents _interactEvents As InteractionEvents
    Private WithEvents _selectEvents As SelectEvents
    Private WithEvents _mouseEvents As MouseEvents

    Private _stillSelecting As Boolean = False
    Private _inventor As Inventor.Application
    Private _symbol As SketchedSymbol

    Public Sub New(ThisApplication As Inventor.Application)
        _inventor = ThisApplication
    End Sub

    Public Sub Pick(symbol As SketchedSymbol)
        _symbol = symbol
        _stillSelecting = True

        _interactEvents = _inventor.CommandManager.CreateInteractionEvents
        _interactEvents.InteractionDisabled = False
        _interactEvents.StatusBarText = "Move the symbol."

        _mouseEvents = _interactEvents.MouseEvents
        _mouseEvents.MouseMoveEnabled = True

        ' start a transaction to stop the flooding of the Undo thing
        Dim transaction = _inventor.TransactionManager.StartTransaction(_inventor.ActiveDocument, "Move Sketch Symbol")
        _interactEvents.Start()
        Do While _stillSelecting
            _inventor.UserInterfaceManager.DoEvents()
        Loop
        _interactEvents.Stop()
        transaction.End()

        _inventor.CommandManager.StopActiveCommand()
    End Sub
    Public Sub onMouseMove(Button As MouseButtonEnum, ShiftKeys As ShiftStateEnum, ModelPosition As Point, ViewPosition As Point2d, View As Inventor.View) Handles _mouseEvents.OnMouseMove
        _symbol.Position = _inventor.TransientGeometry.CreatePoint2d(ModelPosition.X, ModelPosition.Y)
    End Sub
    Public Sub onClick() Handles _mouseEvents.OnMouseClick
        _stillSelecting = False
    End Sub
    Private Sub oInteractEvents_OnTerminate() Handles _interactEvents.OnTerminate
        _stillSelecting = False
    End Sub
End Class

.

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com