microstation vba起步——建立实体


 有人问ms中用vba如何建立一个实体。很简单的一个问题,对照vba.chm,找到method里的
CreateCylinder Method
Generate a Cylinder at origin with SmartSolidElement Type. 
Syntax
Set SmartSolidElement = object.CreateCylinder (Template, radius, height) 
The CreateCylinder method syntax has these parts:
Part Description 
object A valid object. 
radius A Double expression. radius of base plan.  
height A Double expression. height of the cylinder.  
Template An Element expression.  
Version
08.11.09

在ms的vba编辑器中写入

Sub Macro2()
Dim myshape1 As SmartSolidElement
Set myshape1 = SmartSolid.CreateCone(Nothing, 10, 5, 10)
ActiveModelReference.AddElement myshape1
myshape1.Rewrite
End Sub

运行就得到实体了。很简单,可是我找了一个上午。MicroStation_VBA_中文教程中丝毫没有提到如何建立实体。都是建立线、面……vba.chm中根本没有建立实体的代码例子。网络上根本搜不到。根据chm里的方法描述,起先代码是这样的


Sub Macro2()
Dim myshape1 As SmartSolidElement
Set myshape1 = CreateCone(Nothing, 10, 5, 10)
ActiveModelReference.AddElement myshape1
myshape1.Rewrite
End Sub

 
根本通不过。因为参考CreateShapeElement1这个方法如下,它的前面没有object啊。
 
Sub Macro2()
Dim myshape As ShapeElement
Dim shapepoints4(0 To 3) As Point3d
shapepoints4(0).x = 5
shapepoints4(0).y = 5
shapepoints4(1).x = 10
shapepoints4(1).y = 5
shapepoints4(2).x = 10
shapepoints4(2).y = 10
shapepoints4(3).x = 5
shapepoints4(3).y = 10
Set myshape = CreateShapeElement1(Nothing, shapepoints4, msdFillModeFilled)
myshape.FillColor = RGB(250, 250, 250)
ActiveModelReference.AddElement myshape
myshape.Rewrite
End Sub

 最后终于在ms的example文件夹下找到了一个例题SmartSolid.mvba,恍然大悟。



 
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值