If I have a random assortment of points in space, is there a way for me to copy and paste (or array) an object to all selected points using a chosen base point of the object?
Thanks in advance!
If I have a random assortment of points in space, is there a way for me to copy and paste (or array) an object to all selected points using a chosen base point of the object?
Thanks in advance!
Hello - that is a great beginning project to solve using a script, if you have not yet started down that road.
-Pascal
I wish I had the time to take that road. Are you able to point me in the right direction to give me a head start or either tag someone here that could completely fashion it up for us instead.
Cheers!
Hello - this is a quick version - it assumes all the points in the file are target objects.
import scriptcontext as sc
import Rhino
import rhinoscriptsyntax as rs
def CopyToPoints():
ptIds = rs.ObjectsByType(1)
if not ptIds: return
ids = rs.GetObjects("Select objects to copy.")
if not ids: return
basePt = rs.GetPoint("Set point to copy from")
if not basePt: return
for ptId in ptIds:
pt = rs.coercegeometry(ptId)
vecDir = pt.Location-basePt
rs.CopyObjects(ids, vecDir)
if __name__ == '__main__': CopyToPoints()
-Pascal
Forgive me - scripting is not my forte. How do I run this?
I saved it as a .txt file and tried loading script. No luck. I also tried straight up pasting it into the command line and then selecting the .txt file I saved. No luck (get message “unknown command: scriptcontext”).
I’m sure you’ve explained this a million times over somewhere, but I can’t find a simple step by step.
Thank you very much, though, for whacking that together for me - really appreciated!
Hello - save it as a .py file and
To use the Python script use RunPythonScript
, or a macro:
_-RunPythonScript "Full path to py file inside double-quotes"
Here it is as a py:
CopyToPoints2.py (528 Bytes)
-Pascal
Thanks a million <3