(Not macro) awk :input STEP file : output LINE(x,y,1)-(2,3,1) how?

Need help, or want to share a macro? Post here!
mrrclb48z
Posts: 27
Joined: Wed Feb 07, 2018 11:20 am

(Not macro) awk :input STEP file : output LINE(x,y,1)-(2,3,1) how?

Postby mrrclb48z » Tue Mar 20, 2018 11:05 am

1./CARTESIAN_POINT/ (0.E+000,0.E+000) (1.,0.E+000) 3d? 2d?
2./VECTOR/?
3.awk to python converter?

sample
https://qiita.com/mrrclb48z/items/453f410d117f87958bd4

Code: Select all

function name(parameter)
{
     if(index(parameter,"E")==0){
     return parameter
     } else {
     split(parameter,p,"E");ret=p[1] * ( 10 ** p[2] )
     return ret
     }
}
######################################################
/CARTESIAN_POINT/{
a=gensub(/(.+,\()(.+)(\)\)\;)/,"\\1",1,$0);
b=gensub(/(.+,\()(.+)(\)\)\;)/,"\\2",1,$0);
c=gensub(/(.+,\()(.+)(\)\)\;)/,"\\3",1,$0);
n = split(b, array, ",")
if(n==3){
   b1=name(array[1])
   b2=name(array[2])
   b3=name(array[3])
   print a b1 "," b2 "," b3 c
}else if(n==2){
   b1=name(array[1])
   b2=name(array[2])
   print a b1 "," b2 c
}else if(n==1){
   b1=name(array[1])
   print a b1 c
}else if(n=0){
   print $0
}

}
######################################################
/VECTOR/{
print $0
}
######################################################
/LINE/{
n = split($0, array, ",")
p1=array[2]
p2=array[3]
sub(/#/,"",p1)
sub(/#/,"",p2)
sub(/\);/,"",p2)
print $0
}
User avatar
microelly2
Posts: 4690
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: (Not macro) awk :input STEP file : output LINE(x,y,1)-(2,3,1) how?

Postby microelly2 » Tue Mar 20, 2018 11:53 am

I do not realy understand what you want?
Do you want to convert the step file with awk?