some fixes
This commit is contained in:
parent
7cf3b61c54
commit
9a702d20cf
81
src/Mod/Import/App/SCL/Aufspannung.stp
Normal file
81
src/Mod/Import/App/SCL/Aufspannung.stp
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
ISO-10303-21;
|
||||||
|
HEADER;
|
||||||
|
FILE_DESCRIPTION(('CATIA V5 STEP Exchange'),'2;1');
|
||||||
|
|
||||||
|
FILE_NAME('E:\\fem-dev\\src\\Mod\\Import\\App\\SCL\\Aufspannung.stp','2014-01-08T14:51:35+00:00',('none'),('none'),'CATIA Version 5 Release 19 SP 9 (IN-10)','CATIA V5 STEP AP214','none');
|
||||||
|
|
||||||
|
FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }'));
|
||||||
|
|
||||||
|
ENDSEC;
|
||||||
|
/* file written by CATIA V5R19 */
|
||||||
|
DATA;
|
||||||
|
#5=PRODUCT('Aufspannung','','',(#2)) ;
|
||||||
|
#27=PRODUCT('DemlerTisch2000','','',(#2)) ;
|
||||||
|
#50=PRODUCT('Mittelstrebe_ZB-Fr\X2\00E4\X0\sen','','',(#2)) ;
|
||||||
|
#2=PRODUCT_CONTEXT(' ',#1,'mechanical') ;
|
||||||
|
#1=APPLICATION_CONTEXT('automotive design') ;
|
||||||
|
#31=DOCUMENT('1','DemlerTisch2000.CATPart','CATPart document',#30) ;
|
||||||
|
#54=DOCUMENT('2','Mittelstrebe_ZB-Fraesen.CATPart','CATPart document',#53) ;
|
||||||
|
#30=DOCUMENT_TYPE('') ;
|
||||||
|
#53=DOCUMENT_TYPE('') ;
|
||||||
|
#13=PRODUCT_DEFINITION('',' ',#6,#3) ;
|
||||||
|
#3=PRODUCT_DEFINITION_CONTEXT('part definition',#1,' ') ;
|
||||||
|
#16=PRODUCT_DEFINITION_SHAPE(' ',' ',#13) ;
|
||||||
|
#32=PRODUCT_DEFINITION_SHAPE(' ',' ',#29) ;
|
||||||
|
#34=PRODUCT_DEFINITION_SHAPE(' ',' ',#33) ;
|
||||||
|
#55=PRODUCT_DEFINITION_SHAPE(' ',' ',#52) ;
|
||||||
|
#57=PRODUCT_DEFINITION_SHAPE(' ',' ',#56) ;
|
||||||
|
#15=SHAPE_REPRESENTATION(' ',(#38,#61),#22) ;
|
||||||
|
#25=SHAPE_REPRESENTATION(' ',(#39),#24) ;
|
||||||
|
#48=SHAPE_REPRESENTATION(' ',(#62),#47) ;
|
||||||
|
#37=ITEM_DEFINED_TRANSFORMATION(' ',' ',#39,#38) ;
|
||||||
|
#60=ITEM_DEFINED_TRANSFORMATION(' ',' ',#62,#61) ;
|
||||||
|
#38=AXIS2_PLACEMENT_3D(' ',#41,#45,#44) ;
|
||||||
|
#39=AXIS2_PLACEMENT_3D(' ',#40,#43,#42) ;
|
||||||
|
#61=AXIS2_PLACEMENT_3D(' ',#64,#68,#67) ;
|
||||||
|
#62=AXIS2_PLACEMENT_3D(' ',#63,#66,#65) ;
|
||||||
|
#40=CARTESIAN_POINT('NONE',(0.,0.,0.)) ;
|
||||||
|
#41=CARTESIAN_POINT('NONE',(0.,0.,0.)) ;
|
||||||
|
#63=CARTESIAN_POINT('NONE',(0.,0.,0.)) ;
|
||||||
|
#64=CARTESIAN_POINT('NONE',(1302.5,1263.48243402,-125.5)) ;
|
||||||
|
#42=DIRECTION('NONE',(1.,0.,0.)) ;
|
||||||
|
#43=DIRECTION('NONE',(0.,0.,1.)) ;
|
||||||
|
#44=DIRECTION('NONE',(1.,0.,0.)) ;
|
||||||
|
#45=DIRECTION('NONE',(0.,0.,1.)) ;
|
||||||
|
#65=DIRECTION('NONE',(1.,0.,0.)) ;
|
||||||
|
#66=DIRECTION('NONE',(0.,0.,1.)) ;
|
||||||
|
#67=DIRECTION('NONE',(1.,0.,0.)) ;
|
||||||
|
#68=DIRECTION('NONE',(0.,0.,1.)) ;
|
||||||
|
#8=PRODUCT_RELATED_PRODUCT_CATEGORY('part',$,(#27,#50)) ;
|
||||||
|
#11=PRODUCT_RELATED_PRODUCT_CATEGORY('part',$,(#5)) ;
|
||||||
|
#7=PRODUCT_CATEGORY('part','specification') ;
|
||||||
|
#10=PRODUCT_CATEGORY('part','specification') ;
|
||||||
|
#21=UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(0.005),#17,'distance_accuracy_value','CONFUSED CURVE UNCERTAINTY') ;
|
||||||
|
#23=UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(0.005),#17,'distance_accuracy_value','CONFUSED CURVE UNCERTAINTY') ;
|
||||||
|
#46=UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(0.005),#17,'distance_accuracy_value','CONFUSED CURVE UNCERTAINTY') ;
|
||||||
|
#35=CONTEXT_DEPENDENT_SHAPE_REPRESENTATION(#36,#34) ;
|
||||||
|
#58=CONTEXT_DEPENDENT_SHAPE_REPRESENTATION(#59,#57) ;
|
||||||
|
#4=APPLICATION_PROTOCOL_DEFINITION('international standard','automotive_design',2001,#1) ;
|
||||||
|
#33=NEXT_ASSEMBLY_USAGE_OCCURRENCE('DemlerTisch2000.1','DemlerTisch2000.1','',#13,#29,' ') ;
|
||||||
|
#56=NEXT_ASSEMBLY_USAGE_OCCURRENCE('Mittelstrebe_ZB-Fr\X2\00E4\X0\sen.1','Mittelstrebe_ZB-Fr\X2\00E4\X0\sen.1','',#13,#52,' ') ;
|
||||||
|
#29=PRODUCT_DEFINITION_WITH_ASSOCIATED_DOCUMENTS('',' ',#28,#3,(#31)) ;
|
||||||
|
#52=PRODUCT_DEFINITION_WITH_ASSOCIATED_DOCUMENTS('',' ',#51,#3,(#54)) ;
|
||||||
|
#19=PLANE_ANGLE_MEASURE_WITH_UNIT(PLANE_ANGLE_MEASURE(0.0174532925199),#18) ;
|
||||||
|
#9=PRODUCT_CATEGORY_RELATIONSHIP(' ',' ',#7,#8) ;
|
||||||
|
#12=PRODUCT_CATEGORY_RELATIONSHIP(' ',' ',#10,#11) ;
|
||||||
|
#6=PRODUCT_DEFINITION_FORMATION_WITH_SPECIFIED_SOURCE('',' ',#5,.NOT_KNOWN.) ;
|
||||||
|
#28=PRODUCT_DEFINITION_FORMATION_WITH_SPECIFIED_SOURCE('',' ',#27,.NOT_KNOWN.) ;
|
||||||
|
#51=PRODUCT_DEFINITION_FORMATION_WITH_SPECIFIED_SOURCE('',' ',#50,.NOT_KNOWN.) ;
|
||||||
|
#14=SHAPE_DEFINITION_REPRESENTATION(#16,#15) ;
|
||||||
|
#26=SHAPE_DEFINITION_REPRESENTATION(#32,#25) ;
|
||||||
|
#49=SHAPE_DEFINITION_REPRESENTATION(#55,#48) ;
|
||||||
|
#17=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.)) ;
|
||||||
|
#18=(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.)) ;
|
||||||
|
#20=(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT()) ;
|
||||||
|
#22=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#21))GLOBAL_UNIT_ASSIGNED_CONTEXT((#17,#18,#20))REPRESENTATION_CONTEXT(' ',' ')) ;
|
||||||
|
#24=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#23))GLOBAL_UNIT_ASSIGNED_CONTEXT((#17,#18,#20))REPRESENTATION_CONTEXT(' ',' ')) ;
|
||||||
|
#47=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#46))GLOBAL_UNIT_ASSIGNED_CONTEXT((#17,#18,#20))REPRESENTATION_CONTEXT(' ',' ')) ;
|
||||||
|
#36=(REPRESENTATION_RELATIONSHIP(' ',' ',#25,#15)REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION(#37)SHAPE_REPRESENTATION_RELATIONSHIP()) ;
|
||||||
|
#59=(REPRESENTATION_RELATIONSHIP(' ',' ',#48,#15)REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION(#60)SHAPE_REPRESENTATION_RELATIONSHIP()) ;
|
||||||
|
ENDSEC;
|
||||||
|
END-ISO-10303-21;
|
|
@ -106,14 +106,14 @@ class Part21Parser:
|
||||||
self._instances_definition = {}
|
self._instances_definition = {}
|
||||||
# this dict contains lists of 0 ancestors, 1 ancestor, etc.
|
# this dict contains lists of 0 ancestors, 1 ancestor, etc.
|
||||||
# initializes this dict
|
# initializes this dict
|
||||||
self._number_of_ancestors = {}
|
#self._number_of_ancestors = {} # this kind of sorting don't work on non-trivial files
|
||||||
for i in range(2000):
|
#for i in range(2000):
|
||||||
self._number_of_ancestors[i]=[]
|
# self._number_of_ancestors[i]=[]
|
||||||
self.parse_file()
|
self.parse_file()
|
||||||
# reduce number_of_ancestors dict
|
# reduce number_of_ancestors dict
|
||||||
for item in self._number_of_ancestors.keys():
|
#for item in self._number_of_ancestors.keys():
|
||||||
if len(self._number_of_ancestors[item])==0:
|
# if len(self._number_of_ancestors[item])==0:
|
||||||
del self._number_of_ancestors[item]
|
# del self._number_of_ancestors[item]
|
||||||
|
|
||||||
def get_schema_name(self):
|
def get_schema_name(self):
|
||||||
return self._schema_name
|
return self._schema_name
|
||||||
|
@ -140,9 +140,9 @@ class Part21Parser:
|
||||||
instance_id, entity_name, entity_attrs = match_instance_definition.groups()
|
instance_id, entity_name, entity_attrs = match_instance_definition.groups()
|
||||||
instance_int_id = int(instance_id)
|
instance_int_id = int(instance_id)
|
||||||
# find number of ancestors
|
# find number of ancestors
|
||||||
number_of_ancestors = entity_attrs.count('#')
|
#number_of_ancestors = entity_attrs.count('#')
|
||||||
# fill number of ancestors dict
|
# fill number of ancestors dict
|
||||||
self._number_of_ancestors[number_of_ancestors].append(instance_int_id)
|
#self._number_of_ancestors[number_of_ancestors].append(instance_int_id) # this kind of sorting don't work on non-trivial files
|
||||||
# parse attributes string
|
# parse attributes string
|
||||||
entity_attrs_list, str_len = Utils.process_nested_parent_str(entity_attrs)
|
entity_attrs_list, str_len = Utils.process_nested_parent_str(entity_attrs)
|
||||||
# then finally append this instance to the disct instance
|
# then finally append this instance to the disct instance
|
||||||
|
|
|
@ -47,18 +47,19 @@ __version__ = "0.1 (Jan 2014)"
|
||||||
|
|
||||||
|
|
||||||
class SimpleParser:
|
class SimpleParser:
|
||||||
"""
|
""" read the file
|
||||||
Loads all instances definition of a Part21 file into memory.
|
|
||||||
|
Part21.Part21Parser Loads all instances definition of a Part21 file into memory.
|
||||||
Two dicts are created:
|
Two dicts are created:
|
||||||
self._instance_definition : stores attibutes, key is the instance integer id
|
Part21.Part21Parser._instance_definition : stores attibutes, key is the instance integer id
|
||||||
self._number_of_ancestors : stores the number of ancestors of entity id. This enables
|
Part21.Part21Parser._number_of_ancestors : stores the number of ancestors of entity id. This enables
|
||||||
to define the order of instances creation.
|
to define the order of instances creation.
|
||||||
"""
|
"""
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
self._p21loader = Part21.Part21Parser("gasket1.p21")
|
self._p21loader = Part21.Part21Parser(filename)
|
||||||
self._p21loader._number_of_ancestors = {} # not needed, save memory
|
#self._p21loader._number_of_ancestors = {} # not needed, save memory
|
||||||
self.schemaModule = None
|
self.schemaModule = None
|
||||||
self.schemaClasses = None
|
self.schemaClasses = None
|
||||||
self.instanceMape = {}
|
self.instanceMape = {}
|
||||||
|
@ -83,7 +84,9 @@ class SimpleParser:
|
||||||
for i in self._p21loader._instances_definition.keys():
|
for i in self._p21loader._instances_definition.keys():
|
||||||
entityStr = '#'+`i`
|
entityStr = '#'+`i`
|
||||||
nameStr = self._p21loader._instances_definition[i][0].lower()
|
nameStr = self._p21loader._instances_definition[i][0].lower()
|
||||||
sttrStr = `self._p21loader._instances_definition[i][1]`.replace('"','').replace("'",'')
|
sttrStr = `self._p21loader._instances_definition[i][1]`.replace('"','').replace("'",'').replace(" ",'')
|
||||||
|
if len (sttrStr) > 40:
|
||||||
|
sttrStr = sttrStr[:39]+'....'
|
||||||
gvFile.write(' '+`i`+' [label="'+entityStr+'\n'+nameStr+'\n'+sttrStr+'"]\n')
|
gvFile.write(' '+`i`+' [label="'+entityStr+'\n'+nameStr+'\n'+sttrStr+'"]\n')
|
||||||
self._writeGraphVizEdge( i,self._p21loader._instances_definition[i][1],gvFile)
|
self._writeGraphVizEdge( i,self._p21loader._instances_definition[i][1],gvFile)
|
||||||
gvFile.write('}\n')
|
gvFile.write('}\n')
|
||||||
|
@ -162,6 +165,7 @@ class SimpleParser:
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.path.append('..') # path where config_control_design.py is found
|
sys.path.append('..') # path where config_control_design.py is found
|
||||||
parser = SimpleParser("gasket1.p21") # simple test file
|
parser = SimpleParser("Aufspannung.stp") # simple test file
|
||||||
#parser.instaciate()
|
#parser.instaciate()
|
||||||
parser.writeGraphViz('TestGrap.gv')
|
parser.writeGraphViz('TestGrap.gv')
|
||||||
|
#dot.exe -Tsvg -o Test.svg e:\fem-dev\src\Mod\Import\App\SCL\TestGrap-geo.gv
|
||||||
|
|
Loading…
Reference in New Issue
Block a user