点击查看详细介绍

使用SNAP进行UG二次开发-常用曲线(略过了样条线与贝塞尔曲线)

nxopen 12年前 4096 8

购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008  QQ号:85585969  


SNAP资料太少,中文好像没有,先整理下基础资料以便帮助新手快速入门

这儿掠过了 位置,矢量和点的部分,中间涉及到的,稍微看下就会了

(一)直线

Snap.Create类包含几个函数创建线,具体如下:

函数输入与创建方法
Line(x0 As Double, y0 As Double, z0 As Double, x1 As Double, y1 As Double, z1 As Double)使用 起始点,终止点的x, y, z 坐标
Line(x0 As Double, y0 As Double, x1 As Double, y1 As Double)使用起始点,终止点的X,Y坐标(Z值默认为零)
Line(p0 As Position, p1 As Position)使用两个位置创建直线
Line(p0 As Point, p1 As Point)使用两点创建直线(NX.Point objects)

例:

p1 = Point(3,5) ' 创建点 (3,5,0)

q = New Position(2,4,6) ' 创建一个位置(2,4,6)

p2 = Point(q) ' 利用位置’q’创建一个点

Dim c As NX.Line = Line(p1, p2) ' 利用p1 p2点创建一条直线

Line(1,3, 6,8) ' 从点 (1,3,0) 到点 (6,8,0)创建一条直线


注意z坐标,在某些情况下,可以省略。由于经常在xy平面上创建曲线,使用这种默认缺省Z坐标方式,省略了每次输入Z为零的重复操作。


线的属性是:

数据类型属性数据权限描述
PositionStartPointget, set起始点 (point where t = 0).
PositionEndPointget, set终止点 (point where t = 1).
VectorDirectionget直线的矢量方向.

StartPoint EndPoint 的属性允许”set”, 所以可以对已有直线进行编辑:

Dim myLine As NX.Line = Line(2,3,7,8) ' 在点(2,3,0)(7,8,0)点创建直线

myLine.EndPoint = {7,8,5} ' 把直线终点移动到点(7,8,5)

NX.Line类也从NX.Curve类继承了一些有用的特性,如Arclength(弧长):

Dim myLine As NX.Line = Line(0,0,3,4)

Dim length As Double = myLine.Arclength


0

最新回复 (8)
  • nxopen 12年前
    1

    (二)圆弧与圆


    创建圆弧的函数是:

    函数输入与创建方法
    Arc(center As Position, axisX As Vector, axisY As Vector, radius As Double,angle1 As Double, angle2 As Double)(中心位置,X矢量,Y矢量,半径,起始角,终止角)
    Arc(center As Position, matrix As Orientation,radius As Double, angle1 As Double, angle2 As Double)(中心位置,矩阵作为导向,半径,起始角,终止角)
    Arc(center As Position, radius As Double, angle1 As Double, angle2 As Double)(中心位置,半径,起始角,终止角)
    圆弧与XY平面平行
    Arc(cx As Double, cy As Double, radius As Double, angle1 As Double, angle2 As Double)(X坐标,Y坐标,半径,起始角,终止角)
    圆弧在XY 平面上.
    Fillet(p0 As Position, pa As Position, p1 As Position, double radius)(起始位置,通过位置,结束位置,半径)

    创建圆的函数:

    函数输入与创建方法
    Circle(center As Position, axisX As Vector, axisY As Vector, radius As Double)(中心位置,X矢量,Y矢量,半径)
    Circle(center As Position, radius As Double)(中心位置,半径) 在XY平面画圆
    Circle(cx As Double, cy As Double, radius As Double)(X坐标,Y坐标,半径) 在平行于XY平面画圆
    Circle(center As Position, axisZ As Vector, radius As Double)(中心位置,Z轴矢量,半径)
    Circle(p1 As Position, p2 As Position, p3 As Position)(位置1,位置2,位置3)

    直线与圆弧实例:

    Dim length As Double = 8

    Dim width As Double = 4

    Dim half As Double = width/2

    Dim holeDiameter As Double = half

    Line(-half, 0, -half, length) ' 左边直线

    Line( half, 0, half, length) ' 右边直线

    Arc(0, length, half, 0, 180) ' 顶部圆弧(绿色)

    Arc(0, 0, half, 180, 360) ' 底部圆弧(蓝色)

    Circle(0, length, holeDiameter/2) ' 顶部圆孔

    Circle(0, 0, holeDiameter/2)


    圆弧属性:

    数据类型属性数据权限描述
    DoubleRadiusget, set圆弧半径.
    PositionCenterget, set圆弧中心(in absolute coordinates).
    VectorAxisXget圆弧沿X轴的单位矢量 (where angle = 0).
    VectorAxisYget圆弧沿Y轴的单位矢量 (where angle = 90).
    VectorAxisZget圆弧沿Z轴的单位矢量 (normal to its plane).
    doubleStartAngleget起始角 (度数).
    doubleEndAngleget终止角(度数).
    PositionStartPointget圆弧起点 (where angle = StartAngle).
    PositionEndPointget圆弧终点(where angle = EndAngle).

    参考实例代码:

    c1 = Circle(0, 0, 4) ' 在(0,0)点创建半径为4的圆

    p1 = New Position(1, 1) ' 创建一个位置

    p2 = New Position(4, 7) ' 创建位置

    myLine = Line(p1, p2) ' 利用位置 P1 与 P2绘制直线

    v = myLine.Direction ' 获取直线的方向矢量 – (0.6, 0.8, 0)

    c1.Center = p1 + 10*v ' 移动圆C1的圆心点到 (7, 9, 0)

    c1.Radius = 5 ' C1的半径更改为5

    Point(p1.X, p2.Y) ' 利用p1 p2的属性创建一个点(1,7)


    位置与点是不同的,位置仅仅在编程调用时使用,不会出现在绘图输出区域,点(Point)是在工作区绘制一个点


  • 535544858 12年前
    2
  • wsfccdh 12年前
    3

    学习学习..........

  • 465671364 11年前
    4

    学习学习..........

  • 465671364 11年前
    5

    学习学习..........

  • 465671364 11年前
    6

    学习学习..........

  • a7834180 11年前
    7

    正在学习当中,SNAP感觉上会比GRIP稍微简单点。。。支持更新
    我真的好喜欢[b]SNAP-求送--[/b]SNAP函数查询帮助文档(中文版)
    S7834180@163.com
    谢谢!

  • ldczlyp6819 11年前
    8

    SNAP学习中,感谢分享

请登录后发表新帖