<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: drag and drop of an occurrence with a fixed plane in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13649361#M69</link>
    <description>&lt;P&gt;I guess the placement is you are not dragging an occurrence, but client graphics, till you click and place it&lt;BR /&gt;&lt;BR /&gt;Now I need to somehow calc 2d camera position to 3d world but with a fixed Z offset based on workplane selected&lt;BR /&gt;When using the place occurrence command&lt;BR /&gt;&lt;BR /&gt;Or I need to recreate the client graphics myself and make it move based on mouse cursor and workplane&lt;/P&gt;</description>
    <pubDate>Mon, 26 May 2025 08:55:37 GMT</pubDate>
    <dc:creator>Cadkunde.nl</dc:creator>
    <dc:date>2025-05-26T08:55:37Z</dc:date>
    <item>
      <title>drag and drop of an occurrence with a fixed plane</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13646274#M65</link>
      <description>&lt;P&gt;Hello Forum,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a generated assembly of a steel frame.&lt;BR /&gt;After creation of the frame.&lt;BR /&gt;We can make platforms and such.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cadkundenl_1-1747997310119.png" style="width: 680px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1536534i26A104FEBD9BD028/image-dimensions/680x352?v=v2" width="680" height="352" role="button" title="Cadkundenl_1-1747997310119.png" alt="Cadkundenl_1-1747997310119.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But I wish to improve the 'Place Platform' button.&lt;BR /&gt;Ideally, i want to select a workplane, and then have the occurrence under the mouse button dragging it to the desired location while forcing it placed on the previous selected workplane.&lt;BR /&gt;&lt;BR /&gt;Is something like that actually possible?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thx in advance, Arnold&lt;/P&gt;</description>
      <pubDate>Fri, 23 May 2025 11:02:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13646274#M65</guid>
      <dc:creator>Cadkunde.nl</dc:creator>
      <dc:date>2025-05-23T11:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: drag and drop of an occurrence with a fixed plane</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13646387#M66</link>
      <description>&lt;P&gt;I can't be 100% sure without further testing, but it might be possible.&amp;nbsp; When the user manually initiates a 'drag' action, then we can monitor an event for that action, and react to it in a custom way.&amp;nbsp; This is done using the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=UserInputEvents_OnDrag" target="_blank" rel="noopener"&gt;UserInputEvents.OnDrag&lt;/A&gt;&amp;nbsp;event, which we get to through 'Application.CommandManager.UserInputEvents'.&amp;nbsp; You can read more about it on its online help page, which is pretty helpful, but it does not fully explain everything you might need to know.&amp;nbsp; There is also the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=UserInputEventsSink_OnDrag_Sample" target="_blank" rel="noopener"&gt;UserInputEventsSink OnDrag Sample&lt;/A&gt;&amp;nbsp;that you can check out, but it is in VBA (of course&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":face_with_rolling_eyes:"&gt;🙄&lt;/span&gt;), instead of vb.net.&amp;nbsp; You would essentially set the event to 'handled', then as the mouse moves, it keeps reacting, which gets the position of the mouse pointer, both in model space, and in view space, which you can use to 'reposition' (translate) the component.&amp;nbsp; As you get the model position, you may need to 'project' that point in 3D space to that WorkPlane, then use that calculated point in 3D space to dictate where the occurrence gets repositioned to within the event handler.&amp;nbsp; It is not simple to wrap our minds around, and I am not super familiar with the 'projection' step involved, but in theory, it at least sounds possible.&lt;/P&gt;</description>
      <pubDate>Fri, 23 May 2025 12:14:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13646387#M66</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2025-05-23T12:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: drag and drop of an occurrence with a fixed plane</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13646489#M67</link>
      <description>&lt;P&gt;The&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=UserInputEventsSink_OnDrag_Sample" target="_blank" rel="noopener nofollow noreferrer"&gt;UserInputEventsSink OnDrag Sample&lt;/A&gt;&amp;nbsp;seems to give the behaviour im looking for. Thx&lt;BR /&gt;&lt;BR /&gt;I will look into this further&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 May 2025 13:03:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13646489#M67</guid>
      <dc:creator>Cadkunde.nl</dc:creator>
      <dc:date>2025-05-23T13:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: drag and drop of an occurrence with a fixed plane</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13649333#M68</link>
      <description>&lt;P&gt;Well I was a bit too early with saying this solved the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought if I did:&lt;BR /&gt;&lt;BR /&gt;commandmanager.ControlDefinitions("AssemblyPlaceComponentCmd").Execute2(True)&lt;BR /&gt;&lt;BR /&gt;You are 'dragging' the occurrence around the screen.&lt;BR /&gt;But the event does not seem to trigger at that point. only when you place it first, then select and drag.&lt;/P&gt;&lt;P&gt;Perhaps I'm doing something wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe there an option to place the occurrence , then constrain it, then place it 'under the cursor' again?&lt;/P&gt;</description>
      <pubDate>Mon, 26 May 2025 08:35:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13649333#M68</guid>
      <dc:creator>Cadkunde.nl</dc:creator>
      <dc:date>2025-05-26T08:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: drag and drop of an occurrence with a fixed plane</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13649361#M69</link>
      <description>&lt;P&gt;I guess the placement is you are not dragging an occurrence, but client graphics, till you click and place it&lt;BR /&gt;&lt;BR /&gt;Now I need to somehow calc 2d camera position to 3d world but with a fixed Z offset based on workplane selected&lt;BR /&gt;When using the place occurrence command&lt;BR /&gt;&lt;BR /&gt;Or I need to recreate the client graphics myself and make it move based on mouse cursor and workplane&lt;/P&gt;</description>
      <pubDate>Mon, 26 May 2025 08:55:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13649361#M69</guid>
      <dc:creator>Cadkunde.nl</dc:creator>
      <dc:date>2025-05-26T08:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: drag and drop of an occurrence with a fixed plane</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13649765#M70</link>
      <description>&lt;P&gt;Imports Inventor&lt;BR /&gt;Public Class MouseEventChecker&lt;BR /&gt;Private WithEvents oUserInputEvents As UserInputEvents&lt;BR /&gt;Private oIE As InteractionEvents&lt;BR /&gt;Private WithEvents oMouseEvents As MouseEvents&lt;BR /&gt;Private Occ As ComponentOccurrence&lt;BR /&gt;Private Plane As Plane&lt;BR /&gt;Public Sub Initialize(_occ As ComponentOccurrence, _Plane As Plane)&lt;BR /&gt;Occ = _occ&lt;BR /&gt;Plane = _Plane&lt;BR /&gt;oUserInputEvents = Inv.App.CommandManager.UserInputEvents&lt;BR /&gt;oIE = Inv.App.CommandManager.CreateInteractionEvents&lt;BR /&gt;oMouseEvents = oIE.MouseEvents&lt;/P&gt;&lt;P&gt;oMouseEvents.MouseMoveEnabled = True&lt;/P&gt;&lt;P&gt;oIntGraphics = oIE.InteractionGraphics&lt;BR /&gt;oIE.SetCursor(CursorTypeEnum.kCursorBuiltInCommonSketchDrag)&lt;BR /&gt;oIE.Start()&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;Private Sub oMouseEvents_OnMouseMove(ByVal Button As MouseButtonEnum, ByVal ShiftKeys As ShiftStateEnum, ByVal ModelPosition As Point, ByVal ViewPosition As Point2d, ByVal View As View) Handles oMouseEvents.OnMouseMove&lt;BR /&gt;Dim oCamera As Inventor.Camera = Inv.App.ActiveView.Camera&lt;BR /&gt;Dim oVec As Vector = oCamera.Eye.VectorTo(oCamera.Target)&lt;BR /&gt;Dim oTG As TransientGeometry = Inv.App.TransientGeometry&lt;BR /&gt;Dim oLine As Line = oTG.CreateLine(ModelPosition, oVec)&lt;/P&gt;&lt;P&gt;Dim ProjectedPoint As Point = Plane.IntersectWithLine(oLine)&lt;/P&gt;&lt;P&gt;Dim matrix As Matrix = Occ.Transformation&lt;/P&gt;&lt;P&gt;matrix.Cell(1, 4) = ProjectedPoint.X&lt;BR /&gt;matrix.Cell(2, 4) = ProjectedPoint.Y&lt;BR /&gt;matrix.Cell(3, 4) = ProjectedPoint.Z&lt;/P&gt;&lt;P&gt;Occ.Transformation = matrix&lt;/P&gt;&lt;P&gt;oIE.Stop()&lt;BR /&gt;End Sub&lt;BR /&gt;End Class&lt;BR /&gt;&lt;BR /&gt;This is the code that works based on the ondrag example, but instead you need to give an occurrence (you just placed) and a plane (not workplane)&lt;BR /&gt;The onMouseMove event is just triggered once to get Modelposition as point (which is mouse cursor point in 3d space)&lt;/P&gt;</description>
      <pubDate>Mon, 26 May 2025 13:36:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13649765#M70</guid>
      <dc:creator>Cadkunde.nl</dc:creator>
      <dc:date>2025-05-26T13:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: drag and drop of an occurrence with a fixed plane</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13651602#M71</link>
      <description>&lt;P&gt;Guess I forgot that when the 'Place Component' command is active, we are not 'dragging' the component, it is just following our mouse sort of like a preview, until we click to place it.&amp;nbsp; I had looked into the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-AssemblyEvents" target="_blank" rel="noopener"&gt;AssemblyEvents&lt;/A&gt;, but nothing in that collection seemed like a good fit for this exact need.&amp;nbsp; Then the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=FileUIEvents_OnFileInsertDialog" target="_blank" rel="noopener"&gt;FileUIEvents.OnFileInsertDialog&lt;/A&gt;&amp;nbsp;event came to mind, but that only lets us interfere with the 'dialog' portion of the file selection process, not the actual placement portion of the task.&amp;nbsp; Then yes, the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=MouseEvents_OnMouseMove" target="_blank" rel="noopener"&gt;MouseEvents.OnMouseMove&lt;/A&gt;&amp;nbsp;event came to mind, but that also comes with the challenge of how to know when to start (and stop) monitoring for that event.&amp;nbsp; I also looked at the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=SelectEvents_OnPreSelectMouseMove" target="_blank" rel="noopener"&gt;SelectEvents.OnPreSelectMouseMove&lt;/A&gt;&amp;nbsp;event, but component placement does not really seem like a 'pre-select', so that also seemed like a dead end.&amp;nbsp; Besides the 'OnFileInsertDialog' event, I also thought that maybe you could use the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=UserInputEvents_OnActivateCommand" target="_blank" rel="noopener"&gt;UserInputEvents.OnActivateCommand&lt;/A&gt;&amp;nbsp;and the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=UserInputEvents_OnTerminateCommand" target="_blank" rel="noopener"&gt;UserInputEvents.OnTerminateCommand&lt;/A&gt;&amp;nbsp;to 'start' and 'stop' the monitoring window for the 'OnMouseMove' event.&amp;nbsp; It would require knowing all possible 'command' names that could possibly induce the 'place component' scenario, and checking command names within the event.&amp;nbsp; But I guess it could be looked into, if you wanted to.&amp;nbsp; You would have to use 'AddHandler' &amp;amp; 'RemoveHandler' keywords instead of the 'WithEvents' and 'Handles' strategy for setting up your event handlers though.&amp;nbsp; Plus, I'm not sure how you would get the 'continuous' feedback that you are probably looking for.&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2025 12:15:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13651602#M71</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2025-05-27T12:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: drag and drop of an occurrence with a fixed plane</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13651642#M72</link>
      <description>&lt;P&gt;Thx for reply Wesley,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The code triggers when clicking with the mouse in the screen to place a component&lt;BR /&gt;Then onmousemove event keeps triggering many times per second (faster than you can let go of the button you just pressed).&lt;BR /&gt;It triggers once, gives me the mouse location in 3d space, then I finish with oIE.stop and this event is completely stopped.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;It works like a charm, all components are place where the selected XYworkplane.plane and the mousecursor intersect.&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2025 12:44:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/drag-and-drop-of-an-occurrence-with-a-fixed-plane/m-p/13651642#M72</guid>
      <dc:creator>Cadkunde.nl</dc:creator>
      <dc:date>2025-05-27T12:44:27Z</dc:date>
    </item>
  </channel>
</rss>

