Skip to content

Commit

Permalink
Fix bug in import Tessellate - still need to improve code for perform…
Browse files Browse the repository at this point in the history
…ance
  • Loading branch information
KeithSloan committed May 24, 2021
1 parent 59aafd5 commit 1dec648
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 33 deletions.
56 changes: 28 additions & 28 deletions freecad/gdml/GDMLCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,37 +753,37 @@ def Activated(self) :

for obj in FreeCADGui.Selection.getSelection():
print('Action Tessellate 2 Mesh')
print(dir(obj.Proxy))
print(obj.Proxy.Type)
mesh = None
if obj.Proxy.Type == 'GDMLTessellated' :
print('Tessellated2Mesh')
mesh = Tessellated2Mesh(obj)
if hasattr(obj,'Proxy') :
if hasattr(obj.Proxy,'Type') :
mesh = None
if obj.Proxy.Type == 'GDMLTessellated' :
print('Tessellated2Mesh')
mesh = Tessellated2Mesh(obj)

if obj.Proxy.Type == 'GDMLGmshTessellated' :
print('GmshTessellated2Mesh')
mesh = Tessellated2Mesh(obj)
if obj.Proxy.Type == 'GDMLGmshTessellated' :
print('GmshTessellated2Mesh')
mesh = Tessellated2Mesh(obj)

if obj.Proxy.Type == 'GDMLTetrahedron' :
print('Tetrahedron2Mesh')
mesh = Tetrahedron2Mesh(obj)

if mesh != None :
print('Add Mesh')
parent = None
if hasattr(obj,'InList') :
if len(obj.InList) > 0 :
parent = obj.InList[0]
mshObj = parent.newObject('Mesh::Feature',obj.Name)
if parent == None :
mshObj = FreeCAD.ActiveDocument.addObject( \
if obj.Proxy.Type == 'GDMLTetrahedron' :
print('Tetrahedron2Mesh')
mesh = Tetrahedron2Mesh(obj)

if mesh != None :
print('Add Mesh')
parent = None
if hasattr(obj,'InList') :
if len(obj.InList) > 0 :
parent = obj.InList[0]
mshObj = parent.newObject('Mesh::Feature',obj.Name)
if parent == None :
mshObj = FreeCAD.ActiveDocument.addObject( \
'Mesh::Feature',obj.Name)
mshObj.Mesh = mesh
if FreeCAD.GuiUp :
obj.ViewObject.Visibility = False
mshObj.ViewObject.DisplayMode = "Wireframe"
FreeCAD.ActiveDocument.recompute()
FreeCADGui.SendMsgToActiveView("ViewFit")
mshObj.Mesh = mesh
if FreeCAD.GuiUp :
obj.ViewObject.Visibility = False
mshObj.ViewObject.DisplayMode = "Wireframe"
FreeCAD.ActiveDocument.recompute()
FreeCADGui.SendMsgToActiveView("ViewFit")

def GetResources(self):
return {'Pixmap' : 'GDML_Tess2Mesh', 'MenuText': \
Expand Down
5 changes: 1 addition & 4 deletions freecad/gdml/GDMLObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2273,9 +2273,6 @@ def __init__(self, obj, vertex, facets, lunit, material, colour = None) :
obj.ViewObject.ShapeColor = colourMaterial(material)
else :
obj.ViewObject.ShapeColor = colourMaterial(material)
# Suppress Placement - position & Rotation via parent App::Part
# this makes Placement via Phyvol easier and allows copies etc
#obj.addExtension('App::GroupExtensionPython')
self.Type = 'GDMLTessellated'
self.Vertex = vertex
self.Facets = facets
Expand All @@ -2288,7 +2285,7 @@ def onChanged(self, fp, prop):
'''Do something when a property has changed'''
#print(fp.Label+" State : "+str(fp.State)+" prop : "+prop)
if 'Restore' in fp.State :
return
return

if prop in ['material'] :
if FreeCAD.GuiUp :
Expand Down
2 changes: 1 addition & 1 deletion freecad/gdml/importGDML.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ def indexVertex(list,name) :
def createTessellated(part,solid,material,colour,px,py,pz,rot,displayMode) :
from .GDMLObjects import GDMLTessellated, GDMLTriangular, \
GDMLQuadrangular, ViewProvider, ViewProviderExtension
#GDMLShared.setTrace(True)
GDMLShared.trace("CreateTessellated : ")
GDMLShared.trace(solid.attrib)
vertNames = []
Expand Down Expand Up @@ -744,7 +745,6 @@ def createTessellated(part,solid,material,colour,px,py,pz,rot,displayMode) :
+getName(solid))
tess = GDMLTessellated(myTess,vertex,faces,lunit,material,colour)
if FreeCAD.GuiUp :
ViewProviderExtension(myTess.ViewObject)
ViewProvider(myTess.ViewObject)
GDMLShared.trace("Position : "+str(px)+','+str(py)+','+str(pz))
base = FreeCAD.Vector(px,py,pz)
Expand Down

0 comments on commit 1dec648

Please sign in to comment.