-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplaceBlkAtCrvPt.py
More file actions
21 lines (18 loc) · 824 Bytes
/
placeBlkAtCrvPt.py
File metadata and controls
21 lines (18 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import rhinoscriptsyntax as rs
crvIds = rs.GetObjects("Pick curves", rs.filter.curve)
ptIds = rs.GetObjects("Pick points", rs.filter.point)
blockId = rs.GetObject("Pick Block", rs.filter.instance)
if rs.IsBlockInstance(blockId):
block_name = rs.BlockInstanceName(blockId)
for crv in crvIds:
for pt in ptIds:
if rs.IsPointOnCurve(crv, pt):
param = rs.CurveClosestPoint(crv, pt)
tangent = rs.CurveTangent(crv, param)
tangent = rs.VectorUnitize(tangent)
normal = rs.WorldXYPlane().ZAxis
# normal = rs.VectorUnitize(normal)
plane = rs.PlaneFromNormal(pt, normal, tangent)
# plane = rs.CurvePerpFrame(crv, param)
xform = rs.XformChangeBasis(plane, rs.WorldXYPlane())
rs.InsertBlock2(block_name, xform)