def _handleUnits(self): self.unit_schema = 0 self.unit_system = { # standard FreeCAD Base units = unit schema 0 "L": "mm", "M": "kg", "T": "s", "I": "A", "O": "K", "N": "mol", "J": "cd", } param = ParamGet("User parameter:BaseApp/Preferences/Units") self.unit_schema = param.GetInt("UserSchema", 0) if self.unit_schema == 0: Console.PrintMessage( "The FreeCAD standard unit schema mm/kg/s is used. " "Elmer sif-file writing is done in Standard FreeCAD units.\n" ) elif self.unit_schema == 1: Console.PrintMessage( "The SI unit schema m/kg/s is used. " "Elmer sif-file writing is done in SI-units.\n" ) self.unit_system = { "L": "m", "M": "kg", "T": "s", "I": "A", "O": "K", "N": "mol", "J": "cd", } elif self.unit_schema > 1: Console.PrintMessage( "Unit schema: {} not supported by Elmer writer. " "The FreeCAD standard unit schema mm/kg/s is used. " "Elmer sif-file writing is done in Standard FreeCAD units.\n" .format(self.unit_schema) )
def writeThumbnail(data): global _thumbnail _thumbnail = Thumbnail(data) dumpFolder = getDumpFolder() if ((not (dumpFolder is None)) and ParamGet( "User parameter:BaseApp/Preferences/Mod/InventorLoader").GetBool( 'Others.DumpThumbnails', True)): with open(u"%s/_.%s" % (dumpFolder, _thumbnail.type.lower()), 'wb') as thumbnail: thumbnail.write(_thumbnail.getData()) return _thumbnail
def _set_thumbnail(f3d, path): result = False name = path.split('/')[-1] if (name): with f3d.open(path) as thunbnail: data = thunbnail.read() thumbnail = Thumbnail() thumbnail.setIconData(data) dumpFolder = getDumpFolder() if ((not (dumpFolder is None)) and ParamGet( "User parameter:BaseApp/Preferences/Mod/InventorLoader"). GetBool('Others.DumpThumbnails', True)): with open(u"%s/%s" % (dumpFolder, name), 'wb') as png: png.write(data) setThumbnail(thumbnail) result = True return result
def _handleUnits(self): # TODO constants and units # should be only one system for all solver and not in each solver # https://forum.freecadweb.org/viewtopic.php?t=47895 # https://forum.freecadweb.org/viewtopic.php?t=48451 # https://forum.freecadweb.org/viewtopic.php?f=10&t=48642 # The FreeCAD unit schema is only used to determine the schema number # all definition are done here ATM # keep in mind a unit schema might not be consistent: # Length could be mm and Area could be m2 and Volume could be cm3 # as long as only the seven base units are retrieved from a unit schema # the units are consistent # TODO retrieve the seven base units from FreeCAD unit schema # instead of hard coding them here for a second once self.unit_schema = Units.Scheme.SI1 self.unit_system = { # standard FreeCAD Base units = unit schema 0 "L": "mm", "M": "kg", "T": "s", "I": "A", "O": "K", "N": "mol", "J": "cd", } param = ParamGet("User parameter:BaseApp/Preferences/Units") self.unit_schema = param.GetInt("UserSchema", Units.Scheme.SI1) if self.unit_schema == Units.Scheme.SI1: Console.PrintMessage( "The FreeCAD standard unit schema mm/kg/s is used. " "Elmer sif-file writing is done in Standard FreeCAD units.\n") elif self.unit_schema == Units.Scheme.SI2: Console.PrintMessage( "The SI unit schema m/kg/s is used. " "Elmer sif-file writing is done in SI-units.\n") self.unit_system = { "L": "m", "M": "kg", "T": "s", "I": "A", "O": "K", "N": "mol", "J": "cd", } elif self.unit_schema == Units.Scheme.FemMilliMeterNewton: # see also unit comment in calculix writer Console.PrintMessage( "The FEM unit schema mm/N/s is used. " "Elmer sif-file writing is done in FEM-units.\n") self.unit_system = { "L": "mm", "M": "t", "T": "s", "I": "A", "O": "K", "N": "mol", "J": "cd", } elif (self.unit_schema > Units.Scheme.SI2 and self.unit_schema != Units.Scheme.FemMilliMeterNewton): Console.PrintMessage( "Unit schema: {} not supported by Elmer writer. " "The FreeCAD standard unit schema mm/kg/s is used. " "Elmer sif-file writing is done in Standard FreeCAD units.\n". format(Units.listSchemas(self.unit_schema)))
import Fem from . import sifio from .. import settings from femmesh import gmshtools from femtools import constants from femtools import femutils from femtools import membertools _STARTINFO_NAME = "ELMERSOLVER_STARTINFO" _SIF_NAME = "case.sif" _ELMERGRID_IFORMAT = "8" _ELMERGRID_OFORMAT = "2" _SOLID_PREFIX = "Solid" param = ParamGet("User parameter:BaseApp/Preferences/Units") unitsschema = param.GetInt("UserSchema") if unitsschema == 1: Console.PrintMessage("The unit schema m/kg/s is used. So export and " "import is done in ISO units (SI-units).\n") UNITS = { "L": "m", "M": "kg", "T": "s", "I": "A", "O": "K", "N": "mol", "J": "cd", } else:
'd1071d574d61a7c4f2e352bf50116935': 'UCxConstraint3DimensionItem', '7dfcc81711d6419710006eab87ae3483': 'UCxConstructionFolderEntry', '475e786111d296dba0004a803603c8c9': 'UCxFeatureDimensionStateAttr', '2c7020f611d1b3c06000b1b801f31bb0': 'UCxWorkaxisNode', '14533d8211d1087100085ba406e5dc09': 'UCxWorkplaneNode', '2c7020f811d1b3c06000b1b801f31bb0': 'UCxWorkpointNode', 'd31891c248bf14c3aa42ea872a846b2a': 'UFRxRef', } _fileVersion = 0 _fileBeta = -1 _can_import = True _use_sheet_metal = True _block_size = 0 __prmPrefOW__ = ParamGet("User parameter:BaseApp/Preferences/OutputWindow") __prmPrefIL__ = ParamGet( "User parameter:BaseApp/Preferences/Mod/InventorLoader") # The file the be imported _inventor_file = None _dump_folder = None STRATEGY_SAT = 0 STRATEGY_NATIVE = 1 STRATEGY_STEP = 2 STRATEGY_CANCEL = -1 __strategy__ = __prmPrefIL__.GetInt("strategy", STRATEGY_SAT) IS_CELL_REF = re.compile('^[a-z](\d+)?$', re.IGNORECASE)