Fuison 360 API: 判断一个点是否在某曲面上
2016-07-25 12:26
351 查看
原文链接: http://modthemachine.typepad.com/my_weblog/2016/05/is-point-on-face.html
没有直接的方法,不过可以借用SurfaceEvaluator.isParameterOnFace。该方法可返回某个曲面参数是否在曲面上。首先需要知道某个点对应的曲面参数。而getParameterAtPoint返回的是曲面上最接近给定点的点的曲面参数。所以拿到最接近点还得验证一下是否是给定点。以下是个代码测试。
没有直接的方法,不过可以借用SurfaceEvaluator.isParameterOnFace。该方法可返回某个曲面参数是否在曲面上。首先需要知道某个点对应的曲面参数。而getParameterAtPoint返回的是曲面上最接近给定点的点的曲面参数。所以拿到最接近点还得验证一下是否是给定点。以下是个代码测试。
def isPointOnFace(): app = adsk.core.Application.get() ui = app.userInterface selections = app.userInterface.activeSelections sketchPoint = selections.item(0).entity face = selections.item(1).entity evaluator = face.evaluator point = sketchPoint.worldGeometry ui.messageBox( "point, x=" + str(point.x) + "; y=" + str(point.y) + "; z=" + str(point.z)) (returnValue, parameter) = evaluator.getParameterAtPoint(point) ui.messageBox( "parameter, u=" + str(parameter.x) + "; v=" + str(parameter.y)) if not returnValue: # could not get the parameter for it so # it's probably not on the face ui.messageBox("Point not on face\n(Could not get parameter)") return (returnValue, projectedPoint) = evaluator.getPointAtParameter(parameter) ui.messageBox( "projectedPoint, x=" + str(projectedPoint.x) + "; y=" + str(projectedPoint.y) + "; z=" + str(projectedPoint.z)) if not projectedPoint.isEqualTo(point): # the point has been projected in order to get # a parameter so it's not on the face ui.messageBox( "Point not on face\n(Point was projected in order to get parameter)") return returnValue = evaluator.isParameterOnFace(parameter) if not returnValue: ui.messageBox("Point not on face\n(isParameterOnFace says so)") return ui.messageBox("Point on face")
相关文章推荐
- [leetcode] 374. Guess Number Higher or Lower
- iOS--UITextField的简单使用
- Range Sum Query - Immutable
- Range Sum Query - Immutable
- UIScrollViewDelegate Protocol Reference
- 64.Which two statements are true about setting the FAST_START_MTTR_TARGET initialization parameter t
- Sustainability through Energy Load Shaping for Buildings using R
- longestIncreasingSequence最长上升子序列问题
- 63.Examine the values for the following initialization parameters: FAST_START_MTTR_TARGET = 0 LOG_CH
- UIScrollView Class Reference
- CUICatalog: Invalid asset name supplied:
- Camstar Portal modeling user guid --自定义用户菜单
- Could not connect to SMTP host,PKIX path building failed,unable to find valid certification path...
- luigi学习1
- Android子线程居然可以更新UI?
- javaGUI学习——在面板上画一张图片
- soapui工具 简单使用
- HDU 5749 BestCoder Round #84 Colmerauer(暴力贡献)
- HDU1711 Number Sequence KMP基础
- easyui的validatebox