NCF参数化建筑论坛

标题: 两种开发环境比较,vb.net画球并bake [打印本页]

作者: panhao1    时间: 2010-3-12 12:57
标题: 两种开发环境比较,vb.net画球并bake
首先看运算器的代码 Private Sub RunScript(ByVal x As Double, ByVal y As Object, ByRef A As Object) 'your code goes here… Dim center As New On3dPoint(0, 0, 0) Dim radius As Double = x Dim sphere As New OnSphere(center, radius) Dim sphere_srf As OnRevSurface = sphere.RevSurfaceForm() If (sphere_srf Is Nothing) Then A = Nothing End If Dim sphere_obj As New MRhinoSurfaceObject() sphere_obj.SetSurface(sphere_srf) If (doc.AddObject(sphere_obj)) Then doc.Redraw() A = IRhinoCommand.result.success End If End Sub —————————————————————————————————————— 再看VS2005的代码 Public Overrides Function RunCommand(ByVal context As IRhinoCommandContext)_ As IRhinoCommand.result Dim rc As IRhinoCommand.result = IRhinoCommand.result.cancel Dim center As New On3dPoint(0, 0, 0) Dim radius As Double = 5 Dim sphere As New OnSphere(center, radius) Dim sphere_srf As OnRevSurface = sphere.RevSurfaceForm() If (sphere_srf Is Nothing) Then Return rc End If Dim sphere_obj As New MRhinoSurfaceObject() sphere_obj.SetSurface(sphere_srf) If (context.m_doc.AddObject(sphere_obj)) Then context.m_doc.Redraw() rc = IRhinoCommand.result.success End If Return rc End Function
作者: panhao1    时间: 2010-3-12 13:03
本帖最后由 panhao1 于 2010-3-12 13:22 编辑 context.m_doc.Redraw()和doc.redraw用法几乎相同 都来自MRhinoDoc Class AddObject()会返回bol和ID return在sub里面是用不了的(不能返回结果) 改成A=就行了 代码具体思路就是把一个球转成曲面类型 然后输出物体 觉得有用就回个帖 如果没人看 下次就没动力发这类帖子了
作者: panhao1    时间: 2010-3-12 13:27
本帖最后由 panhao1 于 2010-3-12 13:29 编辑 麻烦一点的bake做法 C# 根据自己需求改vb.net if(obj is IOnBrep){ //If a brep, a polysurface or a surface addedObj = doc.AddBrepObject((IOnBrep) obj, att); } else if(obj is IOnMesh) //If a mesh addedObj = doc.AddMeshObject((IOnMesh) obj, att); else if(obj is IOnLine) //If a line (not a curve) addedObj = doc.AddCurveObject(new OnLineCurve((IOnLine) obj), att); else if(obj is IOnArc) //If an arc (not a curve) addedObj = doc.AddCurveObject(new OnArcCurve((IOnArc) obj), att); else if(obj is IOnCircle){ //If a circle (not a curve) OnNurbsCurve crv = new OnNurbsCurve(); ((OnCircle) obj).GetNurbForm(ref crv); addedObj = doc.AddCurveObject(crv, att); } else if(obj is IOnCurve) //If a curve addedObj = doc.AddCurveObject((IOnCurve) obj, att); else if(obj is IOn3dPoint) //If a point addedObj = doc.AddPointObject((IOn3dPoint) obj, att); else if(obj is IArrayOn3dPoint) //If a pointcloud addedObj = doc.AddPointCloudObject((IArrayOn3dPoint) obj, att); else if(obj is IOn3dVector) { //If a vector att.m_object_decoration = IOn.object_decoration.end_arrowhead; addedObj = doc.AddCurveObject(new OnLineCurve(new OnLine(new On3dPoint(0, 0, 0), (new On3dPoint(0, 0, 0)) + (On3dVector) obj)), att); } else if(obj is Grasshopper.Kernel.IGH_BakeAwareData){ //If other strange type of geometry, including Box and Twistedbox Guid gu; ((Grasshopper.Kernel.IGH_BakeAwareData ) obj).BakeGeometry(doc, att, out gu, out addedObj); } else {//Otherwise dont know what to do... continue; }
作者: arceed    时间: 2010-3-12 13:53
顶顶 支持楼主~虽然现在看不懂~先搜藏下来慢慢研究哈 3# panhao1
作者: skywoolf    时间: 2010-3-13 14:36
一直想在GH里创建这样一个球体 [attach]4880[/attach] Panhao感觉用VB好实现不?
作者: panhao1    时间: 2010-3-13 20:20
知道逻辑就很好弄 先搞清楚球的逻辑
作者: liubaolalala    时间: 2010-5-13 21:53
学习了!感谢分享!
作者: jian3vivi    时间: 2010-5-16 23:16
发现强人真的很多啊
作者: ninesuns    时间: 2011-9-7 12:30
楼主能给一个voronoi的代码么,最好用电池的形式给出啊,输出端可以接curve或者brep的。。。
作者: weiwei    时间: 2011-12-29 02:48
原來如此難怪去rhino vb.net 上找到的程式代碼跟grasshopper vb lengcy 上面不太相同。原來是vs2005 的版本
作者: 丞丞    时间: 2012-1-30 17:38
谢谢楼主分享。。。。。
作者: tra    时间: 2012-3-24 19:12
我看的收获是貌似看懂了GH中的数据如何衔接到VB的运算器中来~
作者: hacker    时间: 2012-4-28 14:58
感谢分享啊。
作者: wang19891216    时间: 2012-5-3 14:52
发现强人真的很多啊




欢迎光临 NCF参数化建筑论坛 (http://bbs.ncf-china.com/) Powered by Discuz! X3.2