py3: adapt scripts to work with Python3
This commit is contained in:
@@ -265,13 +265,13 @@ PyObject *PropertyVectorList::getPyObject(void)
|
|||||||
|
|
||||||
void PropertyVectorList::setPyObject(PyObject *value)
|
void PropertyVectorList::setPyObject(PyObject *value)
|
||||||
{
|
{
|
||||||
if (PyList_Check(value)) {
|
if (PySequence_Check(value)) {
|
||||||
Py_ssize_t nSize = PyList_Size(value);
|
Py_ssize_t nSize = PySequence_Size(value);
|
||||||
std::vector<Base::Vector3d> values;
|
std::vector<Base::Vector3d> values;
|
||||||
values.resize(nSize);
|
values.resize(nSize);
|
||||||
|
|
||||||
for (Py_ssize_t i=0; i<nSize;++i) {
|
for (Py_ssize_t i=0; i<nSize;++i) {
|
||||||
PyObject* item = PyList_GetItem(value, i);
|
PyObject* item = PySequence_GetItem(value, i);
|
||||||
PropertyVector val;
|
PropertyVector val;
|
||||||
val.setPyObject( item );
|
val.setPyObject( item );
|
||||||
values[i] = val.getValue();
|
values[i] = val.getValue();
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ __title__="FreeCAD Equipment"
|
|||||||
__author__ = "Yorik van Havre"
|
__author__ = "Yorik van Havre"
|
||||||
__url__ = "http://www.freecadweb.org"
|
__url__ = "http://www.freecadweb.org"
|
||||||
|
|
||||||
import FreeCAD,Draft,ArchComponent,DraftVecUtils,ArchCommands,Units
|
import FreeCAD,Draft,ArchComponent,DraftVecUtils,ArchCommands
|
||||||
|
from FreeCAD import Units
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
import FreeCADGui
|
import FreeCADGui
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ def readPresets():
|
|||||||
for profilefile in profilefiles:
|
for profilefile in profilefiles:
|
||||||
if os.path.exists(profilefile):
|
if os.path.exists(profilefile):
|
||||||
try:
|
try:
|
||||||
with open(profilefile, 'rb') as csvfile:
|
with open(profilefile, 'r') as csvfile:
|
||||||
beamreader = csv.reader(csvfile)
|
beamreader = csv.reader(csvfile)
|
||||||
bid=1 #Unique index
|
bid=1 #Unique index
|
||||||
for row in beamreader:
|
for row in beamreader:
|
||||||
|
|||||||
@@ -490,7 +490,6 @@ class _Stairs(ArchComponent.Component):
|
|||||||
print("Not yet implemented!")
|
print("Not yet implemented!")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class _ViewProviderStairs(ArchComponent.ViewProviderComponent):
|
class _ViewProviderStairs(ArchComponent.ViewProviderComponent):
|
||||||
"A View Provider for Stairs"
|
"A View Provider for Stairs"
|
||||||
def __init__(self,vobj):
|
def __init__(self,vobj):
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
#* *
|
#* *
|
||||||
#***************************************************************************
|
#***************************************************************************
|
||||||
|
|
||||||
import FreeCAD,Draft,ArchComponent,DraftVecUtils,ArchCommands,Units
|
import FreeCAD,Draft,ArchComponent,DraftVecUtils,ArchCommands
|
||||||
|
from FreeCAD import Units
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
import FreeCADGui
|
import FreeCADGui
|
||||||
|
|||||||
@@ -354,9 +354,12 @@ def insert(filename,docname,skip=[],only=[],root=None):
|
|||||||
if DEBUG: print("done.")
|
if DEBUG: print("done.")
|
||||||
|
|
||||||
global ROOT_ELEMENT
|
global ROOT_ELEMENT
|
||||||
|
|
||||||
if root:
|
if root:
|
||||||
ROOT_ELEMENT = root
|
ROOT_ELEMENT = root
|
||||||
|
|
||||||
|
if DEBUG: print ("done.")
|
||||||
|
|
||||||
#global ifcfile # keeping global for debugging purposes
|
#global ifcfile # keeping global for debugging purposes
|
||||||
filename = decode(filename,utf=True)
|
filename = decode(filename,utf=True)
|
||||||
ifcfile = ifcopenshell.open(filename)
|
ifcfile = ifcopenshell.open(filename)
|
||||||
@@ -513,6 +516,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
|
|||||||
except:
|
except:
|
||||||
if DEBUG: print(" ERROR unable to get object representation",)
|
if DEBUG: print(" ERROR unable to get object representation",)
|
||||||
if prepr and (MERGE_MODE_ARCH == 0) and archobj and CREATE_CLONES:
|
if prepr and (MERGE_MODE_ARCH == 0) and archobj and CREATE_CLONES:
|
||||||
|
|
||||||
for s in prepr.Representations:
|
for s in prepr.Representations:
|
||||||
if s.RepresentationIdentifier.upper() == "BODY":
|
if s.RepresentationIdentifier.upper() == "BODY":
|
||||||
if s.Items[0].is_a("IfcMappedItem"):
|
if s.Items[0].is_a("IfcMappedItem"):
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ def importFrd(filename, analysis=None, result_name_prefix=None):
|
|||||||
|
|
||||||
if 'Nodes' in m:
|
if 'Nodes' in m:
|
||||||
positions = []
|
positions = []
|
||||||
for k, v in m['Nodes'].iteritems():
|
for k, v in m['Nodes'].items():
|
||||||
positions.append(v)
|
positions.append(v)
|
||||||
p_x_max, p_y_max, p_z_max = map(max, zip(*positions))
|
p_x_max, p_y_max, p_z_max = map(max, zip(*positions))
|
||||||
p_x_min, p_y_min, p_z_min = map(min, zip(*positions))
|
p_x_min, p_y_min, p_z_min = map(min, zip(*positions))
|
||||||
@@ -454,7 +454,7 @@ def importFrd(filename, analysis=None, result_name_prefix=None):
|
|||||||
strainv = result_set['strainv']
|
strainv = result_set['strainv']
|
||||||
no_of_values = len(disp)
|
no_of_values = len(disp)
|
||||||
displacement = []
|
displacement = []
|
||||||
for k, v in disp.iteritems():
|
for k, v in disp.items():
|
||||||
displacement.append(v)
|
displacement.append(v)
|
||||||
|
|
||||||
x_max, y_max, z_max = map(max, zip(*displacement))
|
x_max, y_max, z_max = map(max, zip(*displacement))
|
||||||
|
|||||||
@@ -41,10 +41,10 @@ def translate(context,text):
|
|||||||
|
|
||||||
s = cStringIO.StringIO()
|
s = cStringIO.StringIO()
|
||||||
for i in u:
|
for i in u:
|
||||||
if ord(i) == 39:
|
if i == 39:
|
||||||
s.write("\\'")
|
s.write("\\'")
|
||||||
else:
|
else:
|
||||||
s.write(i)
|
s.write(chr(i))
|
||||||
t = s.getvalue()
|
t = s.getvalue()
|
||||||
s.close()
|
s.close()
|
||||||
return t
|
return t
|
||||||
@@ -638,7 +638,7 @@ def setColors(html):
|
|||||||
defaults["#textcolor"] = palette.text().color().name()
|
defaults["#textcolor"] = palette.text().color().name()
|
||||||
defaults["#windowcolor"] = palette.window().color().name()
|
defaults["#windowcolor"] = palette.window().color().name()
|
||||||
defaults["#windowtextcolor"] = palette.windowText().color().name()
|
defaults["#windowtextcolor"] = palette.windowText().color().name()
|
||||||
for k,v in defaults.iteritems():
|
for k,v in defaults.items():
|
||||||
html = html.replace(k,str(v))
|
html = html.replace(k,str(v))
|
||||||
return html
|
return html
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user