替换面和 偏置面 尽量不用 grip 去完成(可以用uf函数)
就那 偏置面来说 grip 偏置数值不对 ug会卡死
偏置面
注意!grip偏置面 偏置值不合理就会 出现 死机现象
所以 还是用c语言 【函数 UF_MODL_create_face_offset】 来完成 偏置面比较妥当
entity/obj
number/poin(3)
$$ 输入 参数
l10:
param/'梅雷提示:请输入偏置距离...',$
'偏置距离=',h,resp
jump/l10:,end:,,,resp
$$ 选择对象 面
l20:
mask/71
ident/'梅雷提示请选择目标面...',obj,resp
jump/l10:,end:,,,resp
l30:
$$ 提取面的矢量方向
poin=snorf(obj,.5,.5)
$$ 偏置面
if/h==0,jump/l10:
if/h>0,facmov/obj,trim,height,h,axis,poin(1..3),iferr,bn:
if/h<0,facmov/obj,trim,height,absf(h),axis,-poin(1..3),iferr,bn:
jump/l20:
end:
halt
bn:
print/'梅雷提示:由于参数不符...所以不能偏置此面...'
jump/end:
————————————————————————
批量替换面
entity/body(200),obj(200),box
number/poin1(3),poin2(3),mm(200),nn(200),num1(3,3)
l10:
mask/70
ident/'梅雷提示!请选择目标体...',body,cnt,nm,resp
jump/l10:,end:,,,resp
if/nm>200,messg/'梅雷提示!你选择的对象超过2000个...'
if/nm>200,jump/l10:
l20:
mask/22
ident/'梅雷提示!请选择平面...',box,resp
jump/l10:,end:,,,resp
$$ 提取 面的失量方向
poin1=snorf(box,.5,.5)
if/absf(poin1(1))<>1 and absf(poin1(2))<>1 and absf(poin1(3))<>1,$
messg/'梅雷提示!你选择的面不是正交的 '
if/absf(poin1(1))<>1 and absf(poin1(2))<>1 and absf(poin1(3))<>1,$
jump/l20:
num1(1,1..3)=sposf(box,.5,.5) $$ 取面上的中点
if/absf(poin1(1))==1,vbu=num1(1,1)
if/absf(poin1(2))==1,vbu=num1(1,2)
if/absf(poin1(3))==1,vbu=num1(1,3)
do/l30:,i,1,nm
if/i>nm,jump/l50:
na=&soldat(body(i),face) $$返回 实体上 面的数量
f=0
jump/la:
l30:
l50:
jump/l10:
end:
halt
la:
r=0
do/l40:,j,1,na
if/j>na,jump/l30:
obj(j)=solent/body(i),face,j
faa=&type(obj(j))
if/faa<>22,jump/l40:
poin2=snorf(obj(j),.5,.5)
if/absf(poin2(1))<>1 and absf(poin2(2))<>1 and absf(poin2(3))<>1,$
jump/l40:
if/poin2<>poin1,jump/l40:
r=r+1
nn(r)=j
num1(2,1..3)=sposf(obj(j),.5,.5) $$ 取面上的中点
if/absf(poin1(1))==1,mm(r)=num1(2,1)
if/absf(poin1(2))==1,mm(r)=num1(2,2)
if/absf(poin1(3))==1,mm(r)=num1(2,3)
l40:
if/poin1(1)==1 or poin1(2)==1 or poin1(3)==1,jump/lxz1:
jump/lxz2:
lxz1:
flr=1
if/r<2,jump/lxz3:
ddd=-9999
do/loa1:,f,1,r-1
ddd=maxf(ddd,maxf(mm(f),mm(f+1)))
loa1:
do/loa2:,f,1,r
if/mm(f)==ddd,jump/lxz4:
loa2:
jump/l30:
lxz2:
flr=-1
if/r<2,jump/lxz3:
ddd=9999
do/lob1:,f,1,r-1
ddd=minf(ddd,minf(mm(f),mm(f+1)))
lob1:
do/lob2:,f,1,r
if/mm(f)==ddd,jump/lxz4:
lob2:
jump/l30:
lxz3:
ff=1
jump/lxz5:
lxz4:
ff=f
jump/lxz5:
lxz5: $$________________________
num1(3,1..3)=sposf(obj(nn(ff)),.5,.5) $$ 取面上的中点
if/absf(poin1(1))==1,vby=num1(3,1)
if/absf(poin1(2))==1,vby=num1(3,2)
if/absf(poin1(3))==1,vby=num1(3,3)
eee=vbu-vby
if/eee==0,jump/l30:
if/flr<>1,jump/lxz6:
if/eee>0,facmov/obj(nn(ff)),trim,height,eee,axis,poin1(1..3),iferr,bn:
if/eee<0,facmov/obj(nn(ff)),trim,height,-eee,axis,-poin1(1..3),iferr,bn:
jump/l30:
lxz6:
if/eee>0,facmov/obj(nn(ff)),trim,height,eee,axis,-poin1(1..3),iferr,bn:
if/eee<0,facmov/obj(nn(ff)),trim,height,-eee,axis,poin1(1..3),iferr,bn:
jump/l30:
bn:
messg/'梅雷提示:由于参数不符...所以不能偏置此面...'
jump/end:
_____________________________________________________________________________ _
中磊UG二次开发教程 梅雷著 qq1821117007
学UG就上UG网 http://www.9sug.com/
|