microstation vba起步——建立实体

来源:互联网 发布:国税务网络学校 编辑:程序博客网 时间:2024/05/18 09:04

 有人问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 SmartSolidElementSet myshape1 = SmartSolid.CreateCone(Nothing, 10, 5, 10)ActiveModelReference.AddElement myshape1myshape1.RewriteEnd Sub

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


Sub Macro2()Dim myshape1 As SmartSolidElementSet myshape1 = CreateCone(Nothing, 10, 5, 10)ActiveModelReference.AddElement myshape1myshape1.RewriteEnd Sub

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

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



 
0 0