Inserting geometry at a point

I’m trying to insert a particular geometry at a number of points that are scattered around an area. I’ve gotten my point locations by using the intersect command so I don’t believe I can make them blocks from the start and then edit them. Is there a way to insert geometry, preferably a block, at the point location? For a little more detail please refer to the image I’ve attached. I’m trying to place the red dome cap at each point. Not all points are visible in the image but hopefully this helps in understanding what I’m trying to do.

Hi Chris - presumably you want the obiect oriented to the line even if the lines are not parallel - can’t tell from the image…

This is almost certainly scriptable, copying objects to points is one of the get-you-started tasks in learning scripting in Rhino. Orienting, if that matters, complicates things somewhat however…


Thank you Pascal. Yes. The lines are parallel. The red object wouldn’t need to change orientation at all. Is there a script that currently exists or do you know of a scripting tutorial that would cover this?

Hi Chris - more info here:

Here is a simple example in python - it copies the selected objects to all point objects that are available

import rhinoscriptsyntax as rs

def CopyObjectsToPoints():
    pts = rs.ObjectsByType(1, state=1)
    if not pts:
        print("No target point objects found.")
    ids = rs.GetObjects("Select objects to copy.", preselect=True)
    if not ids:
    pts = [rs.coerce3dpoint(pt) for pt in pts]
    basePt = rs.GetPoint("Set the point to copy from.")
    if not basePt:
    for pt in pts:
        if pt is not None:
            vecDir = pt-basePt
if __name__ == '__main__':
    CopyObjectsToPoints() (646 Bytes)

To use the Python script use RunPythonScript, or a macro:

_-RunPythonScript "Full path to py file inside double-quotes"

@Chris_McKay - updated here for V8

Thank you very much Pascal. This works perfectly!

Looks like I’m having trouble with Python in Rhino8 and I’m getting this error for the script above:
Screen Shot 2023-12-04 at 13.53.33

I didn’t get this error in Rhino7. Also, when I try and run the script in the Python editor in Rhino8 I get this error:

I’m pretty new to python but I’m not sure if this is a me error since the script was working great in rhino7.

Hi Chris, I’ll take a look.

Hm - I’ll look further but at the moment this looks like a bug in ObjectsByType()
RH-78831 Python- rs.ObjectsByType() glitch

I’ll update the script above to work around it.

1 Like

Thank you! The script now works in the script editor but I’m still getting an error when I try and run it via the runPythonScript command

I’m getting the same error I was getting when trying to run it directly:

Hi Chris - that works here - make sure you are saving over the original file that is in the RunPythonScript path with the edited one.


Yes. It’s been saved over the original file. However, the error I’m getting is claiming that Rhino doesn’t have access to the file path that I have saved in my “documents” folder. Would that be something in settings?

I’m still getting the same error.

Ah. There’s the problem. I keep my python scripts in my documents folder.

1 Like

Hey @Chris_McKay, if it should still be relevant, I’ve been using this script via an alias in Rhino for many years. It works great:

ReplacePointsWithBlocks.rvb (1.1 KB)

For the alias:

! _-LoadScript "\\path\ReplacePointsWithBlocks.rvb" _pause _-RunScript "ReplacePointsWithBlocks"

Someone posted this here on the forums years ago, but I can’t find it now. I believe it was Brian Gillespie.

Imo something that should be added to Rhino natively.

I can also recommend Elefront’s block handling for Grasshopper if you need. It can be found on food4rhino.