Arch: misc improvements to materials and IFC

* Improved IFC export of curved surfaces
* Better icon for materials group
* Fixes in IFC export of materials
This commit is contained in:
Yorik van Havre 2015-04-19 16:34:36 -03:00
parent bba2dd581b
commit 4d630dbc32
7 changed files with 800 additions and 59 deletions

View File

@ -423,7 +423,12 @@ def getShapeFromMesh(mesh,fast=True,tolerance=0.001,flat=False,cut=True):
pts = []
for pp in p:
pts.append(FreeCAD.Vector(pp[0],pp[1],pp[2]))
faces.append(Part.Face(Part.makePolygon(pts)))
try:
f = Part.Face(Part.makePolygon(pts))
except:
pass
else:
faces.append(f)
shell = Part.makeShell(faces)
solid = Part.Solid(shell)
solid = solid.removeSplitter()
@ -509,6 +514,14 @@ def meshToShape(obj,mark=True,fast=True,tol=0.001,flat=False,cut=True):
return newobj
return None
def removeCurves(shape,tolerance=5):
'''removeCurves(shape,tolerance=5): replaces curved faces in a shape
with faceted segments'''
import Mesh
t = shape.cleaned().tessellate(tolerance)
m = Mesh.Mesh(t)
return getShapeFromMesh(m)
def removeShape(objs,mark=True):
'''removeShape(objs,mark=True): takes an arch object (wall or structure) built on a cubic shape, and removes
the inner shape, keeping its length, width and height as parameters. If mark is True, objects that cannot

View File

@ -46,8 +46,10 @@ def getMaterialContainer():
for obj in FreeCAD.ActiveDocument.Objects:
if obj.Name == "MaterialContainer":
return obj
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup","MaterialContainer")
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython","MaterialContainer")
obj.Label = "Materials"
_ArchMaterialContainer(obj)
_ViewProviderArchMaterialContainer(obj.ViewObject)
return obj
@ -66,7 +68,7 @@ def getDocumentMaterials():
class _CommandArchMaterial:
"the Arch Material command definition"
def GetResources(self):
return {'Pixmap': 'Arch_Material',
return {'Pixmap': 'Arch_Material_Group',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Material","Set material..."),
'Accel': "M, T",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Material","Creates or edits the material definition of a selected object.")}
@ -90,6 +92,26 @@ class _CommandArchMaterial:
return False
class _ArchMaterialContainer:
"The Material Container"
def __init__(self,obj):
self.Type = "MaterialContainer"
obj.Proxy = self
def execute(self,obj):
return
class _ViewProviderArchMaterialContainer:
"A View Provider for the Material Container"
def __init__(self,vobj):
vobj.Proxy = self
def getIcon(self):
return ":/icons/Arch_Material_Group.svg"
class _ArchMaterial:
"The Material object"
def __init__(self,obj):
@ -97,11 +119,18 @@ class _ArchMaterial:
obj.Proxy = self
def execute(self,obj):
if obj.Material and FreeCAD.GuiUp:
if "Color" in obj.Material:
c = tuple([float(f) for f in obj.Material['Color'].strip("()").split(",")])
for p in obj.InList:
if hasattr(p,"BaseMaterial"):
if p.BaseMaterial.Name == obj.Name:
p.ViewObject.ShapeColor = c
return
class _ViewProviderArchMaterial:
"A View Provider for the MechanicalMaterial object"
"A View Provider for the Material object"
def __init__(self,vobj):
vobj.Proxy = self
@ -158,6 +187,8 @@ class _ArchMaterialTaskPanel:
"sets the task box contents from self.material"
if 'Name' in self.material:
self.form.FieldName.setText(self.material['Name'])
elif self.obj:
self.form.FieldName.setText(self.obj.Label)
if 'Description' in self.material:
self.form.FieldDescription.setText(self.material['Description'])
if 'Color' in self.material:
@ -168,7 +199,6 @@ class _ArchMaterialTaskPanel:
colorPix = QtGui.QPixmap(16,16)
colorPix.fill(self.color)
self.form.ButtonColor.setIcon(QtGui.QIcon(colorPix))
self.form.FieldColor.setText(self.material['Color'])
if 'StandardCode' in self.material:
self.form.FieldCode.setText(self.material['StandardCode'])
if 'ProductURL' in self.material:
@ -188,10 +218,7 @@ class _ArchMaterialTaskPanel:
if hasattr(self.obj,"Material"):
self.obj.Material = self.material
self.obj.Label = self.material['Name']
FreeCADGui.Control.closeDialog()
def reject(self):
FreeCADGui.Control.closeDialog()
FreeCADGui.ActiveDocument.resetEdit()
def chooseMat(self, card):
"sets self.material from a card"

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>223</width>
<width>193</width>
<height>233</height>
</rect>
</property>
@ -82,13 +82,6 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="FieldColor">
<property name="text">
<string>()</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ButtonColor">
<property name="maximumSize">

View File

@ -55,6 +55,7 @@
<file>icons/Git.svg</file>
<file>icons/Arch_Component.svg</file>
<file>icons/Arch_Material.svg</file>
<file>icons/Arch_Material_Group.svg</file>
<file>ui/archprefs-base.ui</file>
<file>ui/archprefs-defaults.ui</file>
<file>ui/archprefs-import.ui</file>

View File

@ -0,0 +1,680 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64px"
height="64px"
id="svg2816"
version="1.1"
inkscape:version="0.48.5 r10040"
sodipodi:docname="Arch_Material.svg">
<defs
id="defs2818">
<linearGradient
inkscape:collect="always"
id="linearGradient4044">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop4046" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop4048" />
</linearGradient>
<linearGradient
id="linearGradient3681">
<stop
id="stop3697"
offset="0"
style="stop-color:#fff110;stop-opacity:1;" />
<stop
style="stop-color:#cf7008;stop-opacity:1;"
offset="1"
id="stop3685" />
</linearGradient>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="64 : 32 : 1"
inkscape:persp3d-origin="32 : 21.333333 : 1"
id="perspective2824" />
<inkscape:perspective
id="perspective3622"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3622-9"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3653"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3675"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3697"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3720"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3742"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3764"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3785"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3806"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3806-3"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3835"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3614"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3614-8"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3643"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3643-3"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3672"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3672-5"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3701"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3701-8"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3746"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
patternTransform="matrix(0.67643728,-0.81829155,2.4578314,1.8844554,-26.450606,18.294947)"
id="pattern5231"
xlink:href="#Strips1_1-4"
inkscape:collect="always" />
<inkscape:perspective
id="perspective5224"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
inkscape:stockid="Stripes 1:1"
id="Strips1_1-4"
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,3.4760987,3.534923)"
height="1"
width="2"
patternUnits="userSpaceOnUse"
inkscape:collect="always">
<rect
id="rect4483-4"
height="2"
width="1"
y="-0.5"
x="0"
style="fill:black;stroke:none" />
</pattern>
<inkscape:perspective
id="perspective5224-9"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,39.618381,8.9692804)"
id="pattern5231-4"
xlink:href="#Strips1_1-6"
inkscape:collect="always" />
<inkscape:perspective
id="perspective5224-3"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
inkscape:stockid="Stripes 1:1"
id="Strips1_1-6"
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,3.4760987,3.534923)"
height="1"
width="2"
patternUnits="userSpaceOnUse"
inkscape:collect="always">
<rect
id="rect4483-0"
height="2"
width="1"
y="-0.5"
x="0"
style="fill:black;stroke:none" />
</pattern>
<pattern
patternTransform="matrix(0.66513382,-1.0631299,2.4167603,2.4482973,-49.762569,2.9546807)"
id="pattern5296"
xlink:href="#pattern5231-3"
inkscape:collect="always" />
<inkscape:perspective
id="perspective5288"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,-26.336284,10.887197)"
id="pattern5231-3"
xlink:href="#Strips1_1-4-3"
inkscape:collect="always" />
<pattern
inkscape:stockid="Stripes 1:1"
id="Strips1_1-4-3"
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,3.4760987,3.534923)"
height="1"
width="2"
patternUnits="userSpaceOnUse"
inkscape:collect="always">
<rect
id="rect4483-4-6"
height="2"
width="1"
y="-0.5"
x="0"
style="fill:black;stroke:none" />
</pattern>
<pattern
patternTransform="matrix(0.42844886,-0.62155849,1.5567667,1.431396,27.948414,13.306456)"
id="pattern5330"
xlink:href="#Strips1_1-9"
inkscape:collect="always" />
<inkscape:perspective
id="perspective5323"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
inkscape:stockid="Stripes 1:1"
id="Strips1_1-9"
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,3.4760987,3.534923)"
height="1"
width="2"
patternUnits="userSpaceOnUse"
inkscape:collect="always">
<rect
id="rect4483-3"
height="2"
width="1"
y="-0.5"
x="0"
style="fill:black;stroke:none" />
</pattern>
<inkscape:perspective
id="perspective5361"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective5383"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective5411"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3681"
id="linearGradient3687"
x1="37.89756"
y1="41.087898"
x2="4.0605712"
y2="40.168594"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3681"
id="linearGradient3695"
x1="31.777767"
y1="40.24213"
x2="68.442062"
y2="54.041203"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.25023482,-0.66040068,0.68751357,0.24036653,-8.7488565,43.149938)" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient12512"
id="radialGradient278"
gradientUnits="userSpaceOnUse"
cx="55"
cy="125"
fx="55"
fy="125"
r="14.375" />
<linearGradient
id="linearGradient12512">
<stop
style="stop-color:#ffffff;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop12513" />
<stop
style="stop-color:#fff520;stop-opacity:0.89108908;"
offset="0.50000000"
id="stop12517" />
<stop
style="stop-color:#fff300;stop-opacity:0.0000000;"
offset="1.0000000"
id="stop12514" />
</linearGradient>
<radialGradient
r="14.375"
fy="125"
fx="55"
cy="125"
cx="55"
gradientUnits="userSpaceOnUse"
id="radialGradient4017"
xlink:href="#linearGradient12512"
inkscape:collect="always" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient12512-2"
id="radialGradient278-5"
gradientUnits="userSpaceOnUse"
cx="55"
cy="125"
fx="55"
fy="125"
r="14.375" />
<linearGradient
id="linearGradient12512-2">
<stop
style="stop-color:#ffffff;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop12513-3" />
<stop
style="stop-color:#ffd820;stop-opacity:0.89108908;"
offset="0.5"
id="stop12517-1" />
<stop
style="stop-color:#ff8000;stop-opacity:0;"
offset="1"
id="stop12514-6" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4044"
id="linearGradient3060"
gradientUnits="userSpaceOnUse"
x1="15.78776"
y1="50.394047"
x2="27.641447"
y2="39.95837" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient12512-2"
id="radialGradient3062"
gradientUnits="userSpaceOnUse"
cx="55"
cy="125"
fx="55"
fy="125"
r="14.375" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4044-2"
id="linearGradient3060-5"
gradientUnits="userSpaceOnUse"
x1="15.78776"
y1="50.394047"
x2="27.641447"
y2="39.95837" />
<linearGradient
inkscape:collect="always"
id="linearGradient4044-2">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop4046-5" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop4048-4" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient12512-2-7"
id="radialGradient3062-5"
gradientUnits="userSpaceOnUse"
cx="55"
cy="125"
fx="55"
fy="125"
r="14.375" />
<linearGradient
id="linearGradient12512-2-7">
<stop
style="stop-color:#ffffff;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop12513-3-4" />
<stop
style="stop-color:#ffd820;stop-opacity:0.89108908;"
offset="0.5"
id="stop12517-1-9" />
<stop
style="stop-color:#ff8000;stop-opacity:0;"
offset="1"
id="stop12514-6-5" />
</linearGradient>
<radialGradient
r="14.375"
fy="125"
fx="55"
cy="125"
cx="55"
gradientUnits="userSpaceOnUse"
id="radialGradient3086"
xlink:href="#linearGradient12512-2-7"
inkscape:collect="always" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4044-5"
id="linearGradient3060-0"
gradientUnits="userSpaceOnUse"
x1="15.78776"
y1="50.394047"
x2="27.641447"
y2="39.95837" />
<linearGradient
inkscape:collect="always"
id="linearGradient4044-5">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop4046-2" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop4048-9" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient12512-2-0"
id="radialGradient3062-4"
gradientUnits="userSpaceOnUse"
cx="55"
cy="125"
fx="55"
fy="125"
r="14.375" />
<linearGradient
id="linearGradient12512-2-0">
<stop
style="stop-color:#ffffff;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop12513-3-7" />
<stop
style="stop-color:#ffd820;stop-opacity:0.89108908;"
offset="0.5"
id="stop12517-1-1" />
<stop
style="stop-color:#ff8000;stop-opacity:0;"
offset="1"
id="stop12514-6-57" />
</linearGradient>
<radialGradient
r="14.375"
fy="125"
fx="55"
cy="125"
cx="55"
gradientUnits="userSpaceOnUse"
id="radialGradient3086-9"
xlink:href="#linearGradient12512-2-0"
inkscape:collect="always" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.8890873"
inkscape:cx="98.799218"
inkscape:cy="37.217592"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:snap-bbox="true"
inkscape:bbox-paths="true"
inkscape:bbox-nodes="true"
inkscape:snap-bbox-edge-midpoints="true"
inkscape:snap-bbox-midpoints="true"
inkscape:object-paths="true"
inkscape:object-nodes="true"
inkscape:window-width="1920"
inkscape:window-height="1053"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:snap-nodes="false"
inkscape:snap-global="false" />
<metadata
id="metadata2821">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<g
id="g3056"
transform="matrix(0.52730336,0,0,0.52730336,30.397738,30.635164)">
<path
transform="matrix(1.2751074,0,0,1.28117,-3.5618174,-19.40621)"
d="m 48.597521,39.95837 c 0,11.57372 -9.382354,20.956074 -20.956074,20.956074 -11.57372,0 -20.9560737,-9.382354 -20.9560737,-20.956074 0,-11.57372 9.3823537,-20.956074 20.9560737,-20.956074 11.57372,0 20.956074,9.382354 20.956074,20.956074 z"
sodipodi:ry="20.956074"
sodipodi:rx="20.956074"
sodipodi:cy="39.95837"
sodipodi:cx="27.641447"
id="path4042"
style="fill:#f4a200;fill-opacity:1;stroke:url(#linearGradient3060);stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0"
sodipodi:type="arc" />
<path
inkscape:export-ydpi="33.852203"
inkscape:export-xdpi="33.852203"
inkscape:export-filename="/home/jimmac/ximian_art/icons/nautilus/suse93/stock_new-16.png"
transform="matrix(0.99878142,0,0,1.0035302,-34.6176,-100.93815)"
d="m 69.375,125 c 0,7.93909 -6.435907,14.375 -14.375,14.375 -7.939093,0 -14.375,-6.43591 -14.375,-14.375 0,-7.93909 6.435907,-14.375 14.375,-14.375 7.939093,0 14.375,6.43591 14.375,14.375 z"
sodipodi:ry="14.375"
sodipodi:rx="14.375"
sodipodi:cy="125"
sodipodi:cx="55"
id="path12511"
style="color:#000000;fill:url(#radialGradient3062);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.25000024;marker:none;visibility:visible;display:block"
sodipodi:type="arc" />
</g>
<g
id="g3056-6"
transform="matrix(0.52730336,0,0,0.52730336,-0.12220968,21.268371)">
<path
transform="matrix(1.2751074,0,0,1.28117,-3.5618174,-19.40621)"
d="m 48.597521,39.95837 c 0,11.57372 -9.382354,20.956074 -20.956074,20.956074 -11.57372,0 -20.9560737,-9.382354 -20.9560737,-20.956074 0,-11.57372 9.3823537,-20.956074 20.9560737,-20.956074 11.57372,0 20.956074,9.382354 20.956074,20.956074 z"
sodipodi:ry="20.956074"
sodipodi:rx="20.956074"
sodipodi:cy="39.95837"
sodipodi:cx="27.641447"
id="path4042-1"
style="fill:#f4a200;fill-opacity:1;stroke:url(#linearGradient3060-5);stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0"
sodipodi:type="arc" />
<path
inkscape:export-ydpi="33.852203"
inkscape:export-xdpi="33.852203"
inkscape:export-filename="/home/jimmac/ximian_art/icons/nautilus/suse93/stock_new-16.png"
transform="matrix(0.99878142,0,0,1.0035302,-34.6176,-100.93815)"
d="m 69.375,125 c 0,7.93909 -6.435907,14.375 -14.375,14.375 -7.939093,0 -14.375,-6.43591 -14.375,-14.375 0,-7.93909 6.435907,-14.375 14.375,-14.375 7.939093,0 14.375,6.43591 14.375,14.375 z"
sodipodi:ry="14.375"
sodipodi:rx="14.375"
sodipodi:cy="125"
sodipodi:cx="55"
id="path12511-1"
style="color:#000000;fill:url(#radialGradient3086);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.25000024;marker:none;visibility:visible;display:block"
sodipodi:type="arc" />
</g>
<g
id="g3056-8"
transform="matrix(0.52730336,0,0,0.52730336,23.790856,-0.84478777)">
<path
transform="matrix(1.2751074,0,0,1.28117,-3.5618174,-19.40621)"
d="m 48.597521,39.95837 c 0,11.57372 -9.382354,20.956074 -20.956074,20.956074 -11.57372,0 -20.9560737,-9.382354 -20.9560737,-20.956074 0,-11.57372 9.3823537,-20.956074 20.9560737,-20.956074 11.57372,0 20.956074,9.382354 20.956074,20.956074 z"
sodipodi:ry="20.956074"
sodipodi:rx="20.956074"
sodipodi:cy="39.95837"
sodipodi:cx="27.641447"
id="path4042-7"
style="fill:#f4a200;fill-opacity:1;stroke:url(#linearGradient3060-0);stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0"
sodipodi:type="arc" />
<path
inkscape:export-ydpi="33.852203"
inkscape:export-xdpi="33.852203"
inkscape:export-filename="/home/jimmac/ximian_art/icons/nautilus/suse93/stock_new-16.png"
transform="matrix(0.99878142,0,0,1.0035302,-34.6176,-100.93815)"
d="m 69.375,125 c 0,7.93909 -6.435907,14.375 -14.375,14.375 -7.939093,0 -14.375,-6.43591 -14.375,-14.375 0,-7.93909 6.435907,-14.375 14.375,-14.375 7.939093,0 14.375,6.43591 14.375,14.375 z"
sodipodi:ry="14.375"
sodipodi:rx="14.375"
sodipodi:cy="125"
sodipodi:cx="55"
id="path12511-7"
style="color:#000000;fill:url(#radialGradient3086-9);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.25000024;marker:none;visibility:visible;display:block"
sodipodi:type="arc" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -838,6 +838,15 @@ def export(exportList,filename):
isi = ifcfile.createIfcStyledItem(None,[psa],None)
isr = ifcfile.createIfcStyledRepresentation(context,"Style","Material",[isi])
imd = ifcfile.createIfcMaterialDefinitionRepresentation(None,None,[isr],mat)
relobjs = []
for o in m.InList:
if hasattr(o,"BaseMaterial"):
if o.BaseMaterial:
if o.BaseMaterial.Name == m.Name:
if o.Name in products:
relobjs.append(products[o.Name])
if relobjs:
ifcfile.createIfcRelAssociatesMaterial(ifcopenshell.guid.compress(uuid.uuid1().hex),history,'MaterialLink','',relobjs,mat)
if DEBUG: print "writing ",filename,"..."
ifcfile.write(filename)
@ -989,42 +998,44 @@ def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tess
curves = True
break
if curves:
shapetype = "triangulated"
tris = fcsolid.tessellate(tessellation)
for tri in tris[1]:
pts = [ifcfile.createIfcCartesianPoint(tuple(tris[0][i])) for i in tri]
loop = ifcfile.createIfcPolyLoop(pts)
bound = ifcfile.createIfcFaceOuterBound(loop,True)
face = ifcfile.createIfcFace([bound])
faces.append(face)
else:
shapetype = "brep"
for fcface in fcsolid.Faces:
loops = []
verts = [v.Point for v in Part.Wire(DraftGeomUtils.sortEdges(fcface.OuterWire.Edges)).Vertexes]
c = fcface.CenterOfMass
v1 = verts[0].sub(c)
v2 = verts[1].sub(c)
n = fcface.normalAt(0,0)
if DraftVecUtils.angle(v2,v1,n) >= 0:
verts.reverse() # inverting verts order if the direction is couterclockwise
pts = [ifcfile.createIfcCartesianPoint(tuple(v)) for v in verts]
loop = ifcfile.createIfcPolyLoop(pts)
bound = ifcfile.createIfcFaceOuterBound(loop,True)
loops.append(bound)
for wire in fcface.Wires:
if wire.hashCode() != fcface.OuterWire.hashCode():
verts = [v.Point for v in Part.Wire(DraftGeomUtils.sortEdges(wire.Edges)).Vertexes]
v1 = verts[0].sub(c)
v2 = verts[1].sub(c)
if DraftVecUtils.angle(v2,v1,DraftVecUtils.neg(n)) >= 0:
verts.reverse()
pts = [ifcfile.createIfcCartesianPoint(tuple(v)) for v in verts]
loop = ifcfile.createIfcPolyLoop(pts)
bound = ifcfile.createIfcFaceBound(loop,True)
loops.append(bound)
face = ifcfile.createIfcFace(loops)
faces.append(face)
#shapetype = "triangulated"
#tris = fcsolid.tessellate(tessellation)
#for tri in tris[1]:
# pts = [ifcfile.createIfcCartesianPoint(tuple(tris[0][i])) for i in tri]
# loop = ifcfile.createIfcPolyLoop(pts)
# bound = ifcfile.createIfcFaceOuterBound(loop,True)
# face = ifcfile.createIfcFace([bound])
# faces.append(face)
fcsolid = Arch.removeCurves(fcsolid)
shapetype = "brep"
for fcface in fcsolid.Faces:
loops = []
verts = [v.Point for v in Part.Wire(DraftGeomUtils.sortEdges(fcface.OuterWire.Edges)).Vertexes]
c = fcface.CenterOfMass
v1 = verts[0].sub(c)
v2 = verts[1].sub(c)
n = fcface.normalAt(0,0)
if DraftVecUtils.angle(v2,v1,n) >= 0:
verts.reverse() # inverting verts order if the direction is couterclockwise
pts = [ifcfile.createIfcCartesianPoint(tuple(v)) for v in verts]
loop = ifcfile.createIfcPolyLoop(pts)
bound = ifcfile.createIfcFaceOuterBound(loop,True)
loops.append(bound)
for wire in fcface.Wires:
if wire.hashCode() != fcface.OuterWire.hashCode():
verts = [v.Point for v in Part.Wire(DraftGeomUtils.sortEdges(wire.Edges)).Vertexes]
v1 = verts[0].sub(c)
v2 = verts[1].sub(c)
if DraftVecUtils.angle(v2,v1,DraftVecUtils.neg(n)) >= 0:
verts.reverse()
pts = [ifcfile.createIfcCartesianPoint(tuple(v)) for v in verts]
loop = ifcfile.createIfcPolyLoop(pts)
bound = ifcfile.createIfcFaceBound(loop,True)
loops.append(bound)
face = ifcfile.createIfcFace(loops)
faces.append(face)
shell = ifcfile.createIfcClosedShell(faces)
shape = ifcfile.createIfcFacetedBrep(shell)
shapes.append(shape)
@ -1033,6 +1044,14 @@ def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tess
# set surface style
if FreeCAD.GuiUp and (not subtraction) and hasattr(obj.ViewObject,"ShapeColor"):
# only set a surface style if the object has no material.
# apparently not needed, no harm in having both.
#m = False
#if hasattr(obj,"BaseMaterial"):
# if obj.BaseMaterial:
# if "Color" in obj.BaseMaterial.Material:
# m = True
#if not m:
rgb = obj.ViewObject.ShapeColor[:3]
if rgb in surfstyles:
psa = surfstyles[rgb]

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>450</width>
<height>599</height>
<height>604</height>
</rect>
</property>
<property name="windowTitle">
@ -545,7 +545,7 @@
<string>Execution Instructions</string>
</property>
<property name="toolTip">
<string>Specific execution or installation insstructions</string>
<string>Specific execution or installation instructions</string>
</property>
<property name="flags">
<set>ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled</set>
@ -879,10 +879,10 @@
</item>
<item>
<property name="text">
<string>Section Fill Pattern</string>
<string>View Linewidth</string>
</property>
<property name="toolTip">
<string>An SVG pattern to apply on cut faces, expressed as either a name of an existing pattern (such as &quot;simple&quot;) or a complete &lt;pattern&gt;...&lt;/pattern&gt; SVG element</string>
<string>An optional linewidth factor for viewed faces</string>
</property>
<property name="text">
<string/>
@ -893,10 +893,18 @@
</item>
<item>
<property name="text">
<string>View Linewidth</string>
<string>Section Color</string>
</property>
<property name="toolTip">
<string>An optional linewidth factor for viewed faces</string>
<string>A base color for sectionned faces, expressed with 3 comma-separated float values, for ex. 0.5,0.5,0.5</string>
</property>
</item>
<item>
<property name="text">
<string>Section Fill Pattern</string>
</property>
<property name="toolTip">
<string>An SVG pattern to apply on cut faces, expressed as either a name of an existing pattern (such as &quot;simple&quot;) or a complete &lt;pattern&gt;...&lt;/pattern&gt; SVG element</string>
</property>
<property name="text">
<string/>