#创建一个草图

#第一个参数传入一个Frame对象

#通过一个点和两个向量创建Frame

#Frame的类成员函数Create被重载

#重载函数1:Frame.Create(Point, Direction)

#第一个参数为一个点

#第二个参数为面法向向量

#重载函数2:Frame. Create(Point, Direction, Direction)

#第一个参数为面上的一个点

#第二个和第三个参数为面上的向量

 

#调用ViewHelper.SetSketchPlane函数在选中对象的基础上创建一个草图

#该函数也重载了两个函数

#重载函数1:SetSketchPlane(ISelection)

#参数为一个Selection的对象

#重载函数2:SetSketchPlane(Plane, ScriptObject)

#第一个参数为前面创建的平面

#第二个参数为可选参数,默认为null

 

#返回一个SetViewModeCommandResult对象
  
 plane = Plane.Create(Frame.Create(Point.Create(MM(0), MM(0), MM(0)), Direction.Create(0, 0, 1), Direction.Create(1, 0, 0)))
 result = ViewHelper.SetSketchPlane(plane)

将space claim导入design_可选参数

 

#旋转草图
 rotationAxis = Line.Create(
    Point.Create(MM(0), MM(0), MM(0)),
    Direction.Create(1, 0, 0)) #定义旋转轴
 matrix = Matrix.Identity #定义一个矩阵
 matrix = matrix * Matrix.CreateRotation(rotationAxis, DEG(90)) #创建一个旋转矩阵
 ViewHelper.TransformSketchPlane(matrix) #将草图旋转一个角度

将space claim导入design_重载函数_02

 

#平移草图
 plane = Plane.Create(Frame.Create(Point.Create(MM(0), MM(20), MM(0)), Direction.Create(0, 0, 1), Direction.Create(1, 0, 0)))
 result = ViewHelper.SetSketchPlane(plane)
 matrix = Matrix.Identity
 matrix = matrix * Matrix.CreateTranslation(Vector.Create(MM(0), MM(20), MM(0)))
 ViewHelper.TransformSketchPlane(matrix)

将space claim导入design_sketch_03

 

#草图转换为三维模式

#转换函数重载了两个函数

#重载函数1 :ViewHelper.SetViewMode(InteractionMode, IScriptObject)

#第一个参数为交互模式,分别为草图模式,剖面模式,三维模式

#第二个参数为可选参数,附加参数,默认值为null

#重载函数2:ViewHelper.SetViewMode(InteractionMode, Plane, IScriptObject)

#第一个参数为交互模式,分别为草图模式,剖面模式,三维模式

#第二个参数为草图平面

#第三个参数为可选参数,附加参数,默认值为null

 

#返回值为一个SetViewModeCommandResult对象

交互模式可选参数

名称

描述

Sketch

0

草图模式

Section

1

剖面模式

Solid

2

三维模式

 

result = ViewHelper.SetViewMode(InteractionMode.Solid)

将space claim导入design_重载函数_04

 

#草图当中创建一条直线

#创建直线函数重载了三个函数

#重载函数1:SketchLine.Create(Point2D, Point2D)

#第一个参数为直线的起点

#第二个参数为直线的终点,起点和终点的坐标皆为激活平面上的二维坐标

#重载函数2:SketchLine. Create(Point, Point, Plane)

#第一个参数为起点坐标

#第二个参数为终点坐标

#第三个参数为可选参数,默认为null,即当前草图

 

#返回一个SketchCurveResult对象

重载函数1示例:
 frame= Frame.Create(Point.Create(MM(0), MM(0), MM(0)), Direction.Create(0, 1, 0), Direction.Create(1, 0, 0))
 plane= Plane.Create(frame)
 ViewHelper.SetSketchPlane(plane)
 start = Point2D.Create(MM(-8), MM(17))
 end = Point2D.Create(MM(-8), MM(-21))
 result = SketchLine.Create(start, end)
  
 重载函数2示例:
 start = Point.Create(MM(-8), MM(17),MM(0))
 end = Point.Create(MM(-8), MM(-21) ,MM(0))
 result = SketchLine.Create(start, end)

将space claim导入design_重载函数_05

 

#草图当中创建一个矩形

#创建矩形的函数重载了三个函数

#重载函数1:SketchRectangle. Create(Point, Point, Point)

#三个参数分别为矩形的三个角上的坐标,从而确定矩形

#重载函数2:SketchRectangle.Create(Point2D, Point2D, Point2D)

#三个参数为矩形的三个角上的坐标,但这个坐标为当前激活平面上的二维坐标

#重载函数3:SketchRectangle. Create(IRectangle)

#参数为IRectangle对象

 

#返回一个SketchCurveResult对象

 

重载函数1示例:
 point1 = Point.Create(MM(15),MM(-15),MM(0))
 point2 = Point.Create(MM(-15),MM(-15),MM(0))
 point3 = Point.Create(MM(-15),MM(15),MM(0))
 result = SketchRectangle.Create(point1, point2, point3)
  
 重载函数2示例:
 plane = Plane.Create(Frame.Create(Point.Create(MM(0), MM(0), MM(0)), Direction.Create(0, 1, 0), Direction.Create(1, 0, 0)))
 result = ViewHelper.SetSketchPlane(plane)
 point1 = Point2D.Create(MM(15),MM(-15))
 point2 = Point2D.Create(MM(-15),MM(-15))
 point3 = Point2D.Create(MM(-15),MM(15))
 result = SketchRectangle.Create(point1, point2, point3)

将space claim导入design_可选参数_06

 

#草图当中创建一个圆形
 #创建矩形的函数重载了三个函数
 #重载函数1:SketchCircle.Create(Point2D, Double)
 #第一个参数为圆心坐标,该坐标位于当前激活的平面上
 #第二个参数为半径
 #重载函数2:SketchCircle.  Create(Point, Double, Plane)
 #第一个参数为圆心
 #第二个参数为半径
 #第三个参数为可选参数,用来指定圆所在平面,默认为null,为当前平面
 #重载函数3:SketchCircle.Create(Circle, Plane)
 #第一个参数为Circle对象
 #第二个参数为可选参数,用来指定圆所在平面,默认为null,为当前平面
  
 #返回一个SketchCurveResult对象
  
 重载函数1示例:
 plane = Plane.Create(Frame.Create(Point.Create(MM(0), MM(0), MM(0)), Direction.Create(0, 1, 0), Direction.Create(1, 0, 0)))
 result = ViewHelper.SetSketchPlane(plane)
 circlepoint= Point2D.Create(MM(0),MM(0))
 SketchCircle.Create(circlepoint, MM(10))
  
 重载函数2示例:
 plane = Plane.Create(Frame.Create(Point.Create(MM(0), MM(0), MM(0)), Direction.Create(0, 1, 0), Direction.Create(1, 0, 0)))
 result = ViewHelper.SetSketchPlane(plane)
 circlepoint= Point.Create(MM(0),MM(0),MM(0))
 SketchCircle.Create(circlepoint, MM(10),plane)
  
 重载函数3示例:
 frame= Frame.Create(Point.Create(MM(0), MM(0), MM(0)), Direction.Create(0, 1, 0), Direction.Create(1, 0, 0))
 plane= Plane.Create(frame)
 radius= MM(10)
 circle=  Circle.Create(frame,radius)
 SketchCircle.Create(circle,plane)

将space claim导入design_ci_07

 

#草图当中创建一个多边形

#只有一个参数,用Polygon对象在草图上创建一个多边形
 #返回一个SketchCurveResult对象
 frame= Frame.Create(Point.Create(MM(0), MM(0), MM(0)), Direction.Create(0, 1, 0), Direction.Create(1, 0, 0))
 innerRadius = MM(18) #内接圆的半径
 numSides = 6 #多边形的边数
 #创建一个多边形的对象
 polygon = Polygon.Create(frame, innerRadius, numSides)
 result = SketchPolygon.Create(polygon)

将space claim导入design_重载函数_08

 

#草图当中创建一段圆弧

#创建圆弧的函数重载了三个函数

#重载函数1:SketchArc.Create(Point, Point, Point)

#第一个参数是圆弧的圆心坐标

#第二个参数是圆弧的起点坐标

#第三个参数是圆弧的终点坐标

#重载函数2:SketchArc.Create(Point2D, Point2D, Point2D)

#三个参数与上面同,但这个坐标为当前激活平面上的二维坐标

#重载函数3:SketchArc.Create(Circle, Interval)

#第一个参数为Circle的对象

#第二个参数为Interval的对象

 

#返回一个SketchCurveResult对象

 

重载函数1示例:

origin = Point.Create(MM(0), MM(0), MM(0))
 start = Point.Create(MM(15), MM(0), MM(0))
 end = Point.Create(MM(0), MM(15), MM(0))
 SketchArc.Create(origin, start, end)

将space claim导入design_可选参数_09

 

重载函数2示例:

frame= Frame.Create(Point.Create(MM(0), MM(0), MM(0)), Direction.Create(0, 1, 0), Direction.Create(1, 0, 0))
 plane= Plane.Create(frame)
 ViewHelper.SetSketchPlane(plane)
 origin = Point2D.Create(MM(0), MM(0))
 start = Point2D.Create(MM(15), MM(0))
 end = Point2D.Create(MM(0), MM(15))
 result = SketchArc.Create(origin, start, end)

将space claim导入design_重载函数_10

 

#草图当中创建样条曲线
 #第一个参数设置样条曲线是否是周期性,也就是样条曲线是否闭合
 #第二个参数传入一个点坐标的列表
 #返回一个SketchCurveResult的对象
 frame= Frame.Create(Point.Create(MM(0), MM(0), MM(0)), Direction.Create(0, 1, 0), Direction.Create(1, 0, 0))
 plane= Plane.Create(frame)
 ViewHelper.SetSketchPlane(plane)
 points = List[Point2D]()
 points.Add(Point2D.Create(MM(-17), MM(-14)))
 points.Add(Point2D.Create(MM(-1), MM(-7)))
 points.Add(Point2D.Create(MM(6), MM(11)))
 points.Add(Point2D.Create(MM(23), MM(19)))
 points.Add(Point2D.Create(MM(29), MM(27)))
 result = SketchNurbs.CreateFrom2DPoints(False, points)

将space claim导入design_重载函数_11

 

#移动一个选中的对象

#MM表示的是以毫米作为单位

#该函数共有三个重载函数

#重载函数1:Move.Execute(ISelection, Vector, MoveOptions)

#第一个参数为选中的对象,可通过Selection.GetActive()获取

#第二个参数为移动的向量

#第三个参数为移动选项

#重载函数2:Move.Execute(ISelection, Frame, TransformType, Vector, MoveOptions)

#第一个参数为选中的对象,可通过Selection.GetActive()获取

#第二个为框架坐标系

#第三个为移动的类型

#第四个参数为移动的向量

#第五个为移动的选项

#重载函数3:Move.Execute(ISelection, Frame, TransformType, Double, MoveOptions)

#第一个参数为选中的对象,可通过Selection.GetActive()获取

#第二个为框架坐标系

#第三个为移动的类型

#第四个参数为移动距离

#第五个为移动的选项

#返回的是一个MoveResult的对象

注:

TransformType参数的取值如下:

名称

描述

TranslateX

0

沿x轴移动

TranslateY

1

沿y轴移动

TranslateZ

2

沿z轴移动

RotateX

3

绕x轴旋转

RotateY

4

绕y轴旋转

RotateZ

5

绕z轴旋转

TranslateXY

6

沿x,y平面移动

TranslateXZ

7

沿x,z平面移动

TranslateYZ

8

沿y,z平面移动

 

重载函数1:

Move.Execute(Selection.GetActive(),Vector.Create(MM(40),MM(0),MM(0)), MoveOptions())

 

重载函数2:

Move.Execute(Selection.GetActive(), Frame.World, TransformType.TranslateX, Vector.Create(MM(40),MM(0),MM(0)), MoveOptions())

 

重载函数3:

Move.Execute(Selection.GetActive(), Frame.World, TransformType.TranslateX, MM(40), MoveOptions())

将space claim导入design_可选参数_12

#填充一个选中的对象

#第一个参数为填充的对象

#第二个参数为可选参数,默认值为null

#第三个参数为可选参数,填充选项,默认值为null

#第四个参数为可选参数,填充模式,默认值为null

#第五个参数为可选参数,默认值为null

#返回一个CommandResult的对象

第四个参数的取值如下:

名称

描述

Sketch

0

Sketch mode

Section

1

Section mode

Layout

2

Layout mode

ThreeD

3

3D mode

 

result = Fill.Execute(Selection.GetActive()) 

将space claim导入design_sketch_13