点击查看详细介绍

请教:grip中的ttype=1,subttype=1之类的是什么意思? 已解决

xiuye1987 6年前 2607 5

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


请教:grip中的ttype=1,subttype=1之类的是什么意思?

0

最新回复 (5)
  • nxopen 6年前
    1

    应该是定义的整数变量吧,完整代码发出来看看呢?

  • xiuye1987 6年前
    2

    $$ 
    $$    主程序,调用的子程序:line-anglf,digit-anglf,create-plane。
    $$
    
    $$实体变量和数组变量申明。
    entity/ent(100000),cenent(100000),result(100000)
    entity/pt(3),precsys,temcsys,pl,ln(2)
    number/mat(12),a(3)
    
    $$保存原始坐标系实体precsys。
    l05:
    pt(1)=point/0,0,0
    blank/pt(1)
    pt(2)=point/1,0,0
    blank/pt(2)
    pt(3)=point/0,1,0
    blank/pt(3)
    precsys=csys/pt(1),pt(2),pt(3)
    delete/pt(1..3)
    
    $$选择进行实体变换的实体。
    l10:
    ident/'Select objects to transform',ent,cnt,num,resp
    jump/trm:,trm:,,resp
    
    $$选择几何变换的功能,含义如前所述。
    l20:
    choose/'Choose option','Translate','Scale','Rotate About a Point',$
             'Mirror Through a Line','Rectangular Array','Circular Array',$
             'Rotate About a line','Mirror Through a Plane',resp
    jump/l10:,trm:,,,T10:,S10:,RP10:,ML10:,RA10:,CA10:,RL10:,MP10:,resp
    
    $$几何变换功能:平移
    
    $$选择平移变换的确定方式:点方式和增量方式。
    T10:
    ttype=1
    choose/'Choose translation method','To a Point','Delta',resp
    jump/l20:,trm:,,,T20:,T50:,resp
    
    $$点方式,选择两个点:参考点和目标点。
    T20:
    gpos/'Select translation reference point',x1,y1,z1,resp
    jump/T10:,trm:,,resp
    T30:
    gpos/'Select translation destination point',x2,y2,z2,resp
    jump/T20:,trm:,,resp
    $$计算点方式的坐标轴平移距离。
    T40:
    dx=x2-x1
    dy=y2-y1
    dz=z2-z1
    jump/T60:
    
    $$增量方式,输入坐标轴平移距离。
    T50:
    param/'Specify translation delta','DXC',dx,'DYC',dy,'DZC',dz,resp
    jump/T10:,trm:,,resp
    
    $$计算平移变换矩阵mat。
    T60:
    mat=matrix/transl,dx,dy,dz
    jump/fin10:
    
    $$几何变换功能:比例缩放。
    
    $$输入比例缩放参考点,并在此参考点上生成临时坐标系实体:temcsys。
    S10:
    ttype=2
    gpos/'Select invariant scale point',x,y,z,resp
    jump/l20:,trm:,,resp
    S20:
    pt(1)=point/x,y,z
    blank/pt(1)
    temcsys=csys/precsys,origin,pt(1)
    delete/pt(1)
    
    $$选择比例缩放系数的确定方式:等比例缩放和不等比例缩放。
    S30:
    choose/'Specify scale type','uniform Scale','Non-uniform Scale',resp
    jump/S10:,trm:,,,S40:,S60:,resp
    
    $$等比例缩放,输入比例系数,同时生成缩放变换矩阵mat。
    S40:
    sca=1.0000
    param/'Enter scale','Scale',sca,resp
    jump/S30:,trm:,,resp
    S50:
    mat=matrix/scale,sca
    jump/fin10:
    
    $$不等比例缩放,输入坐标轴比例系数,同时生成缩放变换矩阵mat。
    S60:
    xscale=1.0000
    yscale=1.0000
    zscale=1.0000
    param/'Enter non-uniform scale','XC-Scale',xscale,'YC-Scale',yscale,$
           'ZC-Scale',zscale,resp
    jump/S30:,trm:,,resp
    S70:
    mat=matrix/scale,xscale,yscale,zscale
    jump/fin10:
    
    $$几何变换功能:绕点旋转。
    
    $$选择旋转参考点,并在此参考点上生成临时坐标系temcsys。
    RP10:
    ttype=3
    gpos/'Select rotation center point',x,y,z,resp
    jump/l20:,trm:,,resp
    RP20:
    pt(1)=point/x,y,z
    blank/pt(1)
    temcsys=csys/precsys,origin,pt(1)
    
    $$选择旋转角度的确定方式:角度方式和两点方式。
    RP30:
    choose/'Specify angle type','Angle Method','Two Point Method',resp
    jump/RP10:,trm:,,,RP40:,RP60:,resp
    
    $$角度方式,输入旋转角度。
    RP40:
    ang=90.0000
    param/'Enter Rotation Angle','Angle',ang,resp
    jump/RP30:,trm:,,resp
    RP50:
    jump/RP90:
    
    $$两点方式,选择两个参考点。
    RP60:
    gpos/'Select point 1',x1,y1,z1,resp
    jump/RP30:,trm:,,resp
    RP70:
    gpos/'Select point 2',x2,y2,z2,resp
    jump/RP60:,trm:,,resp
    $$通过选择的两个点计算旋转角度。
    RP80:
    pt(2)=point/x1,y1,z1
    blank/pt(2)
    pt(3)=point/x2,y2,z2
    blank/pt(3)
    ln(1)=line/pt(1),pt(2)
    blank/ln(1)
    ln(2)=line/pt(1),pt(3)
    blank/ln(2)
    call/'line-anglf',ln(1),ln(2),ang
    delete/pt(1..3),ln(1..2)
    
    $$生成绕点旋转变换矩阵mat。
    RP90:
    mat=matrix/xyrot,ang
    jump/fin10:
    
    $$几何变换功能:直线镜像。
    
    $$选择镜像直线的确定方式:两点方式和直线方式。
    ML10:
    ttype=4
    choose/'Select line to mirror about','Two Points','Existing Line',resp
    jump/l20:,trm:,,,ML20:,ML50:,resp
    
    $$两点方式:选择两个点。
    ML20:
    subttype=1
    gpos/'Line start point',x1,y1,z1,resp
    jump/ML10:,trm:,,resp
    ML30:
    gpos/'Line end point',x2,y2,z2,resp
    jump/ML20:,trm:,,resp
    $$由选择的两个点确定镜像直线。
    ML40:
    pt(1)=point/x1,y1,z1
    blank/pt(1)
    pt(2)=point/x2,y2,z2
    blank/pt(2)
    ln(1)=line/pt(1),pt(2)
    blank/ln(1)
    jump/ML60:
    
    $$直线方式,选择镜像直线。
    ML50:
    subttype=2
    ident/'Select line to mirror about',ln(1),resp
    jump/ML10:,trm:,,resp
    
    $$生成直线镜像矩阵mat。
    ML60:
    mat=matrix/mirror,ln(1)
    if/subttype==1,delete/ln(1)
    jump/fin10:
    
    $$几何变换功能:矩形阵列。
    
    $$选择阵列的两个点:参考点和中心点。
    RA10:
    ttype=5
    gpos/'Select rectangular array reference point',x1,y1,z1,resp
    jump/l20:,trm:,,resp
    RA20:
    gpos/'Select array origin',x2,y2,z2,resp
    jump/RA10:,trm:,,resp
    
    $$生成矩形阵列平移变换矩阵。
    RA30:
    dx=x2-x1
    dy=y2-y1
    dz=z2-z1
    mat=matrix/transl,dx,dy,dz
    
    $$确定矩形阵列参数。
    RA40:
    dxc=1.0000
    dyc=1.0000
    aang=0.0000
    cnums=2.0000
    rnums=2.0000
    param/'Enter array dimensions','DXC',dxc,'DYC',dyc,'Array Angle',aang,$
             'Columns(X)',cnums,'Row(Y)',rnums,resp
    jump/RA20:,trm:,,resp
    RA50:
    jump/fin10:
    
    $$几何变换功能:圆周阵列。
    
    $$选择阵列的两个点:参考点和中心点。
    CA10:
    ttype=6
    gpos/'Select circular array reference point',x1,y1,z1,resp
    jump/l20:,trm:,,resp
    CA20:
    gpos/'Select array orgin',x2,y2,z2,resp
    jump/CA10:,trm:,,resp
    
    $$生成圆周阵列平移变换矩阵。
    CA30:
    dx=x2-x1
    dy=y2-y1
    dz=z2-z1
    mat=matrix/transl,dx,dy,dz
    
    $$确定圆周阵列参数。
    CA40:
    rad=1.0000
    stang=0.0000
    incrang=90.0000
    anum=4.0000
    param/'Enter array dimensions','Radius',rad,'Start Angle',stang,$
             'Angle Increment',incrang,'Number',anum,resp
    jump/CA20:,trm:,,resp
    CA50:
    jump/fin10:
    
    $$几何变换功能:绕直线旋转。
    
    $$选择旋转直线的确定方式:两点方式和直线方式。
    RL10:
    ttype=7
    choose/'Select line to ratate about','Two Points','Existing Line',resp
    jump/l20:,trm:,,,RL20:,RL50:,resp
    
    $$两点方式,选择两个点。
    RL20:
    subttype=1
    gpos/'Line start point',x1,y1,z1,resp
    jump/RL10:,trm:,,resp
    RL30:
    gpos/'Line end point',x2,y2,z2,resp
    jump/Rl20:,trm:,,resp
    $$由选择的两个点生成旋转直线。
    RL40:
    pt(1)=point/x1,y1,z1
    blank/pt(1)
    pt(2)=point/x2,y2,z2
    blank/pt(2)
    ln(1)=line/pt(2),pt(1)
    blank/ln(1)
    jump/RL60:
    
    $$直线方式,选择旋转直线。
    RL50:
    subttype=2
    ident/'Select line to rotate about',ln(1),resp
    jump/RL10:,trm:,,resp
    
    $$利用旋转直线确定临时坐标系temcsys,并输入旋转角度值。
    RL60:
    a(1..3)=&epoint(ln(1))
    pt(1)=point/a(1..3)
    a(1..3)=&spoint(ln(1))
    pt(2)=point/a(1..3)
    pt(3)=point/0,0,0
    blank/pt(1..3)
    call/'2-points-dis',pt(1),pt(3),dist1
    call/'2-points-dis',pt(2),pt(3),dist2
    ifthen/dist1<0.01 or dist2<0.01
            delete/pt(3)
    pt(3)=point/1,0,0
    else
            jump/RL70:
    endif
    RL70:
    temcsys=csys/pt(1),pt(2),pt(3)
    delete/pt(1..3)
    ang=90.0000
    param/'Enter rotation angle','Angle',ang,resp
    jump/RL10:,trm:,,resp
    
    $$生成绕直线旋转变换矩阵mat。
    RL80:
    mat=matrix/yzrot,ang
    jump/fin10:
    
    $$几何变换功能:平面镜像。
    
    $$调用子程序create-plane确定镜像平面。
    MP10:
    ttype=8
    call/'create-plane',judge,operate,pl
    if/judge==0,jump/MP10:
    
    $$生成平面镜像变换矩阵mat。
    MP20:
    mat=matrix/mirror,pl
    if/operate<>1,delete/pl
    jump/fin10:
    
    
    $$选择操作方式:重新选择、移动、复制。
    fin10:
    choose/'Choose operation','Reselect Objects','Move','Copy',resp
    jump/l20:,trm:,,,l10:,fin20:,fin30:,resp
    
    $$若几何实体移动,则operate值为1。
    fin20:
    operate=1
    jump/fin40:
    $$若几何实体复制,则operate值为2。
    fin30:
    operate=2
    
    $$根据几何变换功能类型进行实体变换。
    fin40:
    ifthen/ttype==2 or ttype==3 or ttype==7
            &wcs=temcsys
            ifthen/operate==1
                result=transf/mat,ent(1..num),move
                jump/trm:
            elseif/operate==2
                result=transf/mat,ent(1..num)
                jump/trm:
            else
                jump/trm:
            endif
    elseif/ttype==1 or ttype==4 or ttype==8
            ifthen/operate==1
                result=transf/mat,ent(1..num),move
                jump/trm:
            elseif/operate==2
                result=transf/mat,ent(1..num)
                jump/trm:
            else
                jump/trm:
            endif
    elseif/ttype==5
            jump/fin50:
    elseif/ttype==6
            jump/fin100:
    else
            jump/trm:
    endif
    
    
    $$矩形阵列实现算法。
    fin50:
    cenent=transf/mat,ent(1..num)
    j=-1
    fin60:
    i=-1
    j=j+1
    fin70:
    i=i+1
    dx=dxc*i
    dy=dyc*j
    dis=sqrtf(dx*dx+dy*dy)
    call/'digit-anglf',dx,dy,oriang
    ang=aang+oriang
    x=dis*cosf(ang)
    y=dis*sinf(ang)
    mat=matrix/transl,x,y,0
    ifthen/operate==1
      result=transf/mat,cenent(1..num),move
    elseif/operate==2
            result=transf/mat,cenent(1..num)
    else
            jump/trm:
    endif
    fin80:
    if/i<(cnums-1),jump/fin70:
    if/i==(cnums-1),jump/fin90:
    fin90:
    if/j<(rnums-1),jump/fin60:
    if/j==(rnums-1),jump/trm:
    
    
    $$圆周阵列实现算法。
    fin100:
    cenent=transf/mat,ent(1..num)
    i=-1
    fin110:
    i=i+1
    ang=stang+incrang*i
    x=rad*cosf(ang)
    y=rad*sinf(ang)
    mat=matrix/transl,x,y,0
    ifthen/operate==1
      result=transf/mat,cenent(1..num),move
    elseif/operate==2
            result=transf/mat,cenent(1..num)
    else
            jump/trm:
    endif
    fin120:
    if/i<(anum-1),jump/fin110:
    if/i==(anum-1),jump/fin130:
    fin130:
    delete/cenent(1..num)
    jump/trm:
    
    $$主程序结束。
    trm:
    &wcs=precsys
    halt


  • xiuye1987 6年前
    3

    回复1楼(nxopen): 代码上来了。看完后感觉是立flag,不过在书里没见过这种用法。我看好多变量都不用声明的,grip里的变量是不是都可以不用声明,就直接使用的?

  • nxopen 6年前
    4

    number类型可以不用提前声明,其他的entity、string需要声明

  • xiuye1987 6年前
    5

    回复4楼(nxopen): 明白了,谢谢

请登录后发表新帖