Need help to Recreate Move Command with Custom Direction

Hello grasshoppernians!

So, I want to recreate the move command in pythonscript (if it can be done directly from grasshopper better). This so I can add another option to move in a custom direction (like a preloaded vector), not only vertical or using the normal direction.

To see what I refer to as “options” when you type “move” in the rhino command line, you get these two options:

It would also help if there’s a way to see how this command is structured by default, I don’t know if there is any source code that I can copy to analyze and then modify.

What I am trying to do is to perform an interactive command with the user to modify a point from a curve, but with more options!

Thanks in advance for the help, and I’ll keep searching and document the solution if I find one!

Is it clear what I want? Sorry English is not my first language.

@Frusciante
Hi,
Is this what you’re looking for? This moves an object based on the vector and a specified distance.

import rhinoscriptsyntax as rs
def custom_move():
    obj_id = rs.GetObject("Select object to move")
    if not obj_id:
        return
    start_point = rs.GetPoint("Pick the start point of the vector")
    if not start_point:
        return
    end_point = rs.GetPoint("Pick the end point of the vector")
    if not end_point:
        return
    direction_vector = rs.VectorCreate(end_point, start_point)
    distance = rs.GetReal("Enter distance to move")
    move_vector = rs.VectorScale(rs.VectorUnitize(direction_vector), distance)
    rs.MoveObject(obj_id, move_vector)
custom_move()

Hope this helps,
Farouk

2 Likes

Thanks for your reply, Farouk!

It looks promising, but my limited understanding just doesn’t get why I get the following runtime error.

Runtime error (NotImplementedException): The method or operation is not implemented.

Traceback:
line 235, in GetObject, “C:\Users\DanielGalvánEcheverr\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\selection.py”
line 14, in custom_move, “”
line 28, in script

It looks as if the rs.GetObject() is not properly implemented? Or maybe I’m missing something.

Hi @Frusciante,

What version of Rhino 7 do you have? If you don’t have the latest - go get it.

https://www.rhino3d.com/download/archive/rhino/7/latest/

– Dale

I currently work with Rhino 7 Dale, and I believe it is up to date. Please spare me some wisdom :stuck_out_tongue:

@Frusciante,

Can you run Rhino’s SystemInfo command and post the results?

Thanks,

– Dale

Not sure why you are asking for that information, but here it is anyways.

Rhino 7 SR35 2023-12-12 (Rhino 7, 7.35.23346.11001, Git hash:master @ 6916542aa86609e2c43094fedcff51a3bd3c5723)
License type: Commercial, build 2023-12-12
License details: Cloud Zoo

Windows 10 (10.0.19045 SR0.0) or greater (Physical RAM: 32Gb)

Computer platform: DESKTOP

Standard graphics configuration.
Primary display and OpenGL: NVIDIA GeForce GTX 1660 (NVidia) Memory: 6GB, Driver date: 6-6-2023 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 536.19
> Accelerated graphics device with 4 adapter port(s)
- Windows Main Display attached to adapter port #0

Secondary graphics devices.
Intel(R) UHD Graphics 630 (Intel) Memory: 1GB, Driver date: 4-3-2022 (M-D-Y).
> Integrated graphics device with 3 adapter port(s)
- Secondary monitor attached to adapter port #0

OpenGL Settings
Safe mode: Off
Use accelerated hardware modes: On
Redraw scene when viewports are exposed: On
Graphics level being used: OpenGL 4.6 (primary GPU’s maximum)

Anti-alias mode: 4x
Mip Map Filtering: Linear
Anisotropic Filtering Mode: High

Vendor Name: NVIDIA Corporation
Render version: 4.6
Shading Language: 4.60 NVIDIA
Driver Date: 6-6-2023
Driver Version: 31.0.15.3619
Maximum Texture size: 32768 x 32768
Z-Buffer depth: 24 bits
Maximum Viewport size: 32768 x 32768
Total Video Memory: 6 GB

Rhino plugins that do not ship with Rhino
C:\Users\DanielGalvánEcheverr\DUO\200_RD - D\02_AutoLot3d\01 AutoCivil\Lista de Plugins\PLUGINS\elefront422 (2)\elefront421\ElefrontProperties.rhp “ElefrontProperties” 1.0.0.0
C:\Users\DanielGalvánEcheverr\Downloads\rhinoplugin\RhinoToGrasshopper.rhp “RhinoToGrasshopper” 1.0.0.0

Rhino plugins that ship with Rhino
C:\Program Files\Rhino 7\Plug-ins\Commands.rhp “Commands” 7.35.23346.11001
C:\Program Files\Rhino 7\Plug-ins\rdk.rhp “Renderer Development Kit”
C:\Program Files\Rhino 7\Plug-ins\RhinoRenderCycles.rhp “Rhino Render” 7.35.23346.11001
C:\Program Files\Rhino 7\Plug-ins\rdk_etoui.rhp “RDK_EtoUI” 7.35.23346.11001
C:\Program Files\Rhino 7\Plug-ins\rdk_ui.rhp “Renderer Development Kit UI”
C:\Program Files\Rhino 7\Plug-ins\NamedSnapshots.rhp “Snapshots”
C:\Program Files\Rhino 7\Plug-ins\IronPython\RhinoDLR_Python.rhp “IronPython” 7.35.23346.11001
C:\Program Files\Rhino 7\Plug-ins\RhinoCycles.rhp “RhinoCycles” 7.35.23346.11001
C:\Program Files\Rhino 7\Plug-ins\Grasshopper\GrasshopperPlugin.rhp “Grasshopper” 7.35.23346.11001
C:\Program Files\Rhino 7\Plug-ins\Toolbars\Toolbars.rhp “Toolbars” 7.35.23346.11001
C:\Program Files\Rhino 7\Plug-ins\3dxrhino.rhp “3Dconnexion 3D Mouse”
C:\Program Files\Rhino 7\Plug-ins\Displacement.rhp “Displacement”

Hi,
Reinstalling Rhino should resolve the problem. @Frusciante
Maybe Dale knows a more efficient way to fix the Python Interpreter bug without having to reinstall Rhino.

Farouk

1 Like

Thanks guys! I’ll try re-installing then. But anyways, thanks for the script Farouk, appreciate it!