NCF参数化建筑论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 21424|回复: 13
打印 上一主题 下一主题

[VB & C#] 两种开发环境比较,vb.net画球并bake

[复制链接]
跳转到指定楼层
1m
发表于 2010-3-12 12:57:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先看运算器的代码 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

评分

参与人数 1强度 +3 照度 +30 收起 理由
skywoolf + 3 + 30

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享
2m
 楼主| 发表于 2010-3-12 13:03:42 | 只看该作者
本帖最后由 panhao1 于 2010-3-12 13:22 编辑 context.m_doc.Redraw()和doc.redraw用法几乎相同 都来自MRhinoDoc Class AddObject()会返回bol和ID return在sub里面是用不了的(不能返回结果) 改成A=就行了 代码具体思路就是把一个球转成曲面类型 然后输出物体 觉得有用就回个帖 如果没人看 下次就没动力发这类帖子了
3m
 楼主| 发表于 2010-3-12 13:27:57 | 只看该作者
本帖最后由 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; }
4m
发表于 2010-3-12 13:53:40 | 只看该作者
顶顶 支持楼主~虽然现在看不懂~先搜藏下来慢慢研究哈 3# panhao1
5m
发表于 2010-3-13 14:36:46 | 只看该作者
一直想在GH里创建这样一个球体
6m
 楼主| 发表于 2010-3-13 20:20:28 | 只看该作者
知道逻辑就很好弄 先搞清楚球的逻辑
7m
发表于 2010-5-13 21:53:06 | 只看该作者
学习了!感谢分享!
8m
发表于 2010-5-16 23:16:09 | 只看该作者
发现强人真的很多啊
9m
发表于 2011-9-7 12:30:15 | 只看该作者
楼主能给一个voronoi的代码么,最好用电池的形式给出啊,输出端可以接curve或者brep的。。。
10m
发表于 2011-12-29 02:48:24 | 只看该作者
原來如此難怪去rhino vb.net 上找到的程式代碼跟grasshopper vb lengcy 上面不太相同。原來是vs2005 的版本
11m
发表于 2012-1-30 17:38:31 | 只看该作者
谢谢楼主分享。。。。。
12m
发表于 2012-3-24 19:12:48 | 只看该作者
我看的收获是貌似看懂了GH中的数据如何衔接到VB的运算器中来~
13m
发表于 2012-4-28 14:58:50 | 只看该作者
感谢分享啊。
14m
发表于 2012-5-3 14:52:26 | 只看该作者
发现强人真的很多啊

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

GMT+8, 2024-4-28 11:49 , Processed in 0.352510 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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