Commit 0a7d9bc3 authored by Jonathan Wiedemann's avatar Jonathan Wiedemann

Add IFC format

parent 0b608c76
......@@ -34,7 +34,7 @@ SECRET_KEY = '$8!z49%d5nkzoi5scdg&v&wqdi4)r-cyi&m=+m=22qt1&cat69'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = [u'freecad-france.com']
ALLOWED_HOSTS = [u'freecad-france.com',u'fxc.freecad-france.com']
# Application definition
......@@ -110,3 +110,4 @@ USE_TZ = True
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
......@@ -28,7 +28,7 @@ __author__ = "Jonathan Wiedemann"
__url__ = "https://www.freecad-france.com"
import sys, getopt
import sys
FREECADPATH='/usr/lib/freecad/lib'
sys.path.append(FREECADPATH)
import FreeCAD, Draft, Part, DraftGeomUtils
......@@ -49,35 +49,45 @@ def getFreeCADVersion() :
def load3dfile( path, label ) :
"""load a file in FreeCAD and return its freecad document name"""
labelsplit = label.rsplit( '.' , 1 )
filename = labelsplit[0]
fileextension = labelsplit[1].lower()
doc = FreeCAD.newDocument( filename )
doc = FreeCAD.newDocument( labelsplit[0] )
filename = doc.Name
doc.Label = label
if fileextension in [ "fcstd", ] :
doc.load( path )
if fileextension in [ "step", "stp", "iges", "igs", "brp", "brep" ] :
elif fileextension in [ "step", "stp", "iges", "igs", "brp", "brep" ] :
import Part
Part.insert( path, filename )
if fileextension in [ "stl", "obj", "bms", "off", "ply", "ast" ] :
elif fileextension in [ "stl", "obj", "bms", "off", "ply", "ast" ] :
import Mesh
Mesh.insert( path, filename )
if fileextension in [ "dae" ] :
elif fileextension in [ "dae" ] :
import importDAE
importDAE.insert(path, filename )
elif fileextension in [ "ifc" ] :
## Need to make some change in ArchMaterial.py in freecad code.
## Add some if FreeCADGui up.
import importIFC
importIFC.insert(path, filename )
else :
pass
if DEBUG:
print('FreeCADConnect.load3dfile report ...')
print(' path was', path)
print(' label was', label)
print(' FC Doc instance', doc)
print(' FC Doc Name', doc.Name)
print(' FC Doc Label', doc.Label)
print(' FC Doc FileName', doc.FileName)
print('... end FreeCADConnect.load3dfile.')
print( 'FreeCADConnect.load3dfile report ...' )
print( ' path was', path )
print( ' label was', label )
print( ' FC Doc instance', doc )
print( ' FC Doc Name', doc.Name )
print( ' FC Doc Label', doc.Label )
print( ' FC Doc FileName', doc.FileName )
print( '... end FreeCADConnect.load3dfile.' )
return doc.Name
def getInstanceDoc( name ):
......@@ -125,7 +135,16 @@ def getMESH(doc, path, extension):
def getIFC( doc, path, extension ):
print("IFC is not implemented")
"""IFC export ( ifc ) for the given doc"""
objectsList = getVisibleObjects( doc )
filepath = path + '.' + extension.lower()
import importIFC
importIFC.export( objectsList,filepath )
if DEBUG:
print( "FreeCADConnect.getIFC report ..." )
print( " getIFC filepath :" + filepath )
print( "... FreeCADConnect.getIFC end." )
return filepath
def getPART( doc, path, extension ):
"""PART export (step, iges, brep) for the given doc"""
......@@ -168,8 +187,13 @@ def closeDocument(label):
FreeCAD.closeDocument(self.doc.Name)
def getVisibleObjects(doc):
if DEBUG :
print( 'FreeCADConnect.getVisibleObjects report ...' )
print( ' len(doc.Objects) : ', len(doc.Objects) )
if not doc.FileName :
visibleObjectList = doc.Objects
if DEBUG :
print( " len(visibleObjectList) : ", len(visibleObjectList) )
return visibleObjectList
else :
import zipfile
......@@ -190,6 +214,8 @@ def getVisibleObjects(doc):
for name in visibleObjectNameList :
visibleObjectList.append(doc.getObject(name))
return visibleObjectList
if DEBUG :
print( '... end FreeCADConnect.getVisibleObjects.' )
def getThreeJS(doc):
tab = " " # the tab size
......
......@@ -30,7 +30,7 @@
<div class="jumbotron">
<h1 class="text-center">Visionneuse et convertisseur de modèles 3D</h1>
<hr class="my-2">
<p>Choisisir un modèle 3D de votre ordinateur puis cliquer sur "Ouvrir"</p>
<p>Choisir un modèle 3D de votre ordinateur puis cliquer sur "Ouvrir"</p>
<form action="{% url 'preview' %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<p>{{ form.docfile }}
......@@ -80,64 +80,59 @@
</thead>
<tbody>
<tr>
<td>STL (*.stl) : Maillage STL</td>
<td>&#10004;</td>
<td>&#10004;</td>
<td><a href = "https://fr.wikipedia.org/wiki/Fichier_de_st%C3%A9r%C3%A9olithographie" > STL ( *.stl ) </a></td>
<td style = "color:green;" > &#10004; </td>
<td style = "color:green;" > &#10004; </td>
</tr>
<tr>
<td>OBJ (*.obj) : Maillage OBJ</td>
<td>&#10004;</td>
<td>&#10004;</td>
<td><a href = "https://fr.wikipedia.org/wiki/Objet_3D_(format_de_fichier)" > OBJ ( *.obj ) </a></td>
<td style = "color:green;" > &#10004; </td>
<td style = "color:green;" > &#10004; </td>
</tr>
<tr>
<td>STEP (*.stp, *.step) : Solide STEP</td>
<td>&#10004;</td>
<td>&#10004;</td>
<td><a href = "https://fr.wikipedia.org/wiki/Objet_3D_(format_de_fichier)" > STEP ( *.stp, *.step ) </a></td>
<td style = "color:green;" > &#10004; </td>
<td style = "color:green;" > &#10004; </td>
</tr>
<tr>
<td>BREP</td>
<td>&#10004;</td>
<td>&#10004;</td>
<td> <a href = "https://fr.wikipedia.org/wiki/B-Rep" > BREP (*.brp, *.brep) </a> </td>
<td style = "color:green;" > &#10004; </td>
<td style = "color:green;" > &#10004; </td>
</tr>
<tr>
<td>IGES</td>
<td>&#10004;</td>
<td>&#10004;</td>
<td> <a href = "https://fr.wikipedia.org/wiki/Initial_Graphics_Exchange_Specification" > IGES ( *.igs, *.iges ) </a> </td>
<td style = "color:green;" > &#10004; </td>
<td style = "color:green;" > &#10004; </td>
</tr>
<tr>
<td>DAE</td>
<td>&#10004;</td>
<td>&#10004;</td>
<td> <a href = "https://fr.wikipedia.org/wiki/Collaborative_Design_Activity" > DAE ( *.dae ) </a> </td>
<td style = "color:green;" > &#10004; </td>
<td style = "color:green;" > &#10004; </td>
</tr>
<tr>
<td>IFC</td>
<td>&#10008;</td>
<td>&#10008;</td>
<td> <a href = "https://fr.wikipedia.org/wiki/Industry_Foundation_Classes" > IFC ( *.ifc ) </a> </td>
<td style = "color:green;" > &#10004; </td>
<td style = "color:green;" > &#10004; </td>
</tr>
<tr>
<td>AST (*.ast) : Maillage AST</td>
<td>&#10004;</td>
<td>&#10004;</td>
<td> <a href = "https://www.freecad-france.com" > AST ( *.ast ) </a> </td>
<td style = "color:green;" > &#10004; </td>
<td style = "color:green;" > &#10004; </td>
</tr>
<tr>
<td>BMS</td>
<td>&#10004;</td>
<td>&#10004;</td>
<td> <a href = "https://www.freecad-france.com" > BMS ( *.bms ) </a> </td>
<td style = "color:green;" > &#10004; </td>
<td style = "color:green;" > &#10004; </td>
</tr>
<tr>
<td>PLY</td>
<td>&#10004;</td>
<td>&#10004;</td>
<td> <a href = "https://www.freecad-france.com" > PLY ( *.ply ) </a> </td>
<td style = "color:green;" > &#10004; </td>
<td style = "color:green;" > &#10004; </td>
</tr>
<tr>
<td>SCAD</td>
<td>&#10008;</td>
<td>&#10008;</td>
</tr>
<tr>
<td>FCSTD</td>
<td>&#10004;</td>
<td>&#10004;</td>
<td> <a href = "https://freecadweg.org" > FCSTD ( *.fcstd , *.FCStd ) </a> </td>
<td style = "color:green;" > &#10004; </td>
<td style = "color:green;" > &#10004; </td>
</tr>
</tbody>
</table>
......
......@@ -56,6 +56,7 @@
<option value="BMS" > BMS </option>
<option value="AST" > AST </option>
<option value="OFF" > OFF </option>
<option value="IFC" > IFC </option>
</select></br>
</div>
<div class="col-md-4">
......
......@@ -68,6 +68,7 @@ def Export(request):
'BMS' : 'model',
'BREP' : 'model',
'DAE' : 'model',
'IFC' : 'model',
}
if request.method == 'POST':
# the value of the choosen format
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment