NCF参数化建筑论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 13397|回复: 5
打印 上一主题 下一主题

[在线求助] 有谁能帮我解释rhinoscript101中平面框架遇到的问题

[复制链接]
跳转到指定楼层
1m
发表于 2013-12-6 17:07:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Call WhoFramedTheSurface()
Sub WhoFramedTheSurface()
Dim idSurface : idSurface = Rhino.GetObject("Surface to frame", 8, True, True)
If IsNull(idSurface) Then Exit Sub
Dim intCount : intCount = Rhino.GetInteger("Number of iterations per direction", 20, 2)
If IsNull(intCount) Then Exit Sub
Dim uDomain : uDomain = Rhino.SurfaceDomain(idSurface, 0)
Dim vDomain : vDomain = Rhino.SurfaceDomain(idSurface, 1)
Dim uStep : uStep = (uDomain(1) - uDomain(0)) / intCount
Dim vStep : vStep = (vDomain(1) - vDomain(0)) / intCount
Dim u, v
Dim pt
Dim srfFrame
Call Rhino.EnableRedraw(False)
For u = uDomain(0) To uDomain(1) Step uStep
For v = vdomain(0) To vDomain(1) Step vStep
pt = Rhino.EvaluateSurface(idSurface, Array(u, v))
If Rhino.Distance(pt, Rhino.BrepClosestPoint(idSurface, pt)(0)) < 0.1 Then就是这一行我不明白(原文中的解释是:21 和22 行做了一些有趣的事情,但在旁边的图释上并未显现。当我们处理裁剪过的表面(trimmed surfaces)的时候,
这两行会阻止脚本在剪去的区域(cut-away areas)内添加平面。通过比较(未裁剪的)表面上的点和它们在裁剪
过的表面上的投影,我们可以知道上述的{uv}坐标是否代表着裁剪过的表面上一个真实的点。

srfFrame = Rhino.SurfaceFrame(idSurface, Array(u, v))
Call Rhino.AddPlaneSurface(srfFrame, 1.0, 1.0)
End If
Next
Next
Call Rhino.EnableRedraw(True)
End Sub
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享
2m
发表于 2013-12-6 19:28:20 | 只看该作者
本帖最后由 794779857lock 于 2013-12-6 21:50 编辑

If Rhino.Distance(pt, Rhino.BrepClosestPoint(idSurface, pt)(0)) < 0.1 Then
这是用两点之间的距离小于0.1来判断是否点在被剪辑的曲面上
因为你要在一个曲面上找一个点,那么这个曲面可能是被裁剪过的,当你想用曲面的UV定义曲面上的一个点的时候,使用的是被裁剪过之前的曲面的UV,而根据UV值得到的曲面上的点就可能是在曲面外的,Rhino.BrepClosestPoint(idSurface, pt)是用你现在的点找到被裁剪之前的曲面上的最近点(如果没被裁剪过,可能就是重合的)。Rhino.Distance(pt, Rhino.BrepClosestPoint(idSurface, pt)(0))是用这个投影的点与原来的点的点测量距离,如果小于0.1可以被认为是重合,那么这个点就在被裁剪的曲面上(误差0.1)。
python里的说明:
BrepClosestPoint
Returns the point on a surface or polysurface that is closest to a test point. This function works on both untrimmed and trimmed surfaces.

Syntax
rhinoscriptsyntax.BrepClosestPoint (object_id, point)

rhinoscript.surface.BrepClosestPoint (object_id, point)

Parameters
object_id
Required. String or Guid. The object's identifier.

point
Required.  List of three numbers or Point3d.  The test, or sampling, point.


Returns
List
An array of closest point information if successful.  The list will contain the following information:

Element
Type
Description

0
Point3d
The 3-D point at the parameter value of the closest point.

1
List (U, V)
Parameter values of closest point.  Note, V is 0 if the component index type is brep_edge or brep_vertex.

2
List (type, index)
The type and index of the brep component that contains the closest point. Possible types are brep_face, brep_edge or brep_vertex.

3
Vector3d
The normal to the  brep_face, or the tangent to the brep_edge.  


None
If not successful, or on error.




Distance
Measures the distance between two 3-D points, or between a 3-D point and an array of 3-D points.

Syntax
rhinoscriptsyntax.Distance (point1, point2)

rhinoscript.utility.Distance (point1, point2)

Parameters
point1
Required.  List of 3 numbers or Point3d.  The first 3-D point.

point2
Required.  point or list of points.


Returns
Number
If point1 and point2 are specified as single points, then the distance is successful.

List
If point2 is a list of points, then a List of distances if successful.

None
If not successful, or on error.

3m
发表于 2013-12-8 18:43:34 | 只看该作者
弱弱地问一句,楼上两位用python吗?
4m
 楼主| 发表于 2013-12-9 11:37:36 | 只看该作者

谢谢,lock大神解答。十分的感谢!
5m
 楼主| 发表于 2013-12-9 11:39:27 | 只看该作者
0.000 发表于 2013-12-8 18:43
弱弱地问一句,楼上两位用python吗?

没有,我学的是vbscript
6m
发表于 2013-12-12 10:41:11 | 只看该作者
谢谢楼主共享源码

小黑屋|手机版|NCF参数化建筑论坛 ( 浙ICP备2020044100号-2 )    辽公网安备21021102000973号

GMT+8, 2024-12-18 09:49 , Processed in 0.355513 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表