Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
303 views
in Technique[技术] by (71.8m points)

java - Regex for instances in STEP-files?

I have to parse some STEP-files (ISO-10303-21) from different CAD-Systems and they are always structured differently. This are the forms that might appear:

#95=STYLED_ITEM('',(#94),#92);
#12 = CARTESIAN_POINT ( 'NONE',  ( 1.213489432997839200,
5.617300827691964000, -7.500000000000001800 ) ) ;
#263 = TEST ( 'Spaces must not be ignored here' ) ;

I thought that a regular expression would help me, so I created this one (http://rubular.com/r/EtJ25Hfg77):

(#d+)s*=s*([A-Z_]+)s*(s*(.*)*s*)s*;

This gives me:

Match 1:
1: #95
2: STYLED_ITEM
3:

Match 2:
1: #12
2: CARTESIAN_POINT
3:

Match 3:
1: #263
2: TEST
3:

So the first two groups are working as supposed. But I also need the attributes inside the parantheses like this:

Match 1:
1: #95
2: STYLED_ITEM
3: ''
4: (#94)
5: #92

Match 2:
1: #12
2: CARTESIAN_POINT
3: 'NONE'
4: ( 1.213489432997839200, 5.617300827691964000, -7.500000000000001800 )

Match 3:
1: #263
2: TEST
3: 'Spaces must not be ignored here'

Please help me finding the correct expression for the last group ((.*) at the moment).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

With an AGPL license for non-commercial use JSDAI is free and open source java toolkit for working with STEP files

http://www.jsdai.net/

BSD license, so always free and open source is the STEPcode project which generates C++ and python API's and example STEP file reader/writer, which is used by other open source projects such as BRL-CAD, SCView and OpenVSP.

www.stepcode.org

OpenCasCade has C++, pythonOCC has python, and node-occ has javascript API's for working with data that is translated from STEP, and are also free and open source. OCE works across more platforms and has more bug fixes

https://github.com/tpaviot/oce


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...