[Part::CheckGeometry] pass object to buildShapeContent() rather than string as docname.objname

This commit is contained in:
mwganson
2022-01-04 16:40:42 -06:00
committed by wmayer
parent ddbf8e0e2d
commit c93c0e6aaf
3 changed files with 11 additions and 12 deletions

View File

@@ -12,12 +12,11 @@ import FreeCAD as App
def roundVector(v,dec):
return str([round(v[0],dec), round(v[1],dec), round(v[2],dec)])
def buildShapeContent(basename, decimals=2, advancedShapeContent=True):
obj = basename[basename.index('.')+1:] #note: obj is a string, so is doc
doc = basename[:basename.index(obj)-1]
shp = App.getDocument(doc).getObject(obj).Shape
def buildShapeContent(obj, decimals=2, advancedShapeContent=True):
shp = obj.Shape
typeStr = str(shp.ShapeType)
result = doc+'.'+App.getDocument(doc).getObject(obj).Label+' ('+obj+'):\n'
lbl = '' if obj.Name == obj.Label else '(' + obj.Label + ')'
result = obj.Name + lbl + '\n'
result += 'Shape type: '+typeStr+'\n'
result += 'Vertices: '+str(len(shp.Vertexes))+'\n'
result += 'Edges: '+str(len(shp.Edges))+'\n'
@@ -65,9 +64,9 @@ def buildShapeContent(basename, decimals=2, advancedShapeContent=True):
result += str(p)+': '+roundVector(props[p],decimals) +'\n'
else:
result += str(p)+': '+str(props[p])+'\n'
object = App.getDocument(doc).getObject(obj)
if object.getGlobalPlacement() != object.Placement:
rpl = object.getGlobalPlacement() * object.Placement.inverse()
if obj.getGlobalPlacement() != obj.Placement:
rpl = obj.getGlobalPlacement() * obj.Placement.inverse()
rot = rpl.Rotation
if hasattr(shp, 'CenterOfMass'):
result += 'Global CenterOfMass: '+roundVector(rpl.multVec(shp.CenterOfMass),decimals)+'\n'

View File

@@ -451,7 +451,7 @@ void TaskCheckGeometryResults::goCheck()
checkedCount++;
checkedMap.Clear();
buildShapeContent(baseName, shape);
buildShapeContent(sel.pObject, baseName, shape);
BRepCheck_Analyzer shapeCheck(shape);
if (!shapeCheck.IsValid())
@@ -585,7 +585,7 @@ void TaskCheckGeometryResults::checkSub(const BRepCheck_Analyzer &shapeCheck, co
}
}
void TaskCheckGeometryResults::buildShapeContent(const QString &baseName, const TopoDS_Shape &shape)
void TaskCheckGeometryResults::buildShapeContent(App::DocumentObject *pObject, const QString &baseName, const TopoDS_Shape &shape)
{
bool advancedShapeContent = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->
@@ -603,7 +603,7 @@ void TaskCheckGeometryResults::buildShapeContent(const QString &baseName, const
throw Py::Exception();
}
Py::Tuple args(3);
args.setItem(0, Py::String(baseName.toStdString().c_str()));
args.setItem(0, Py::asObject(pObject->getPyObject()));
args.setItem(1, Py::Long(decimals));
args.setItem(2, Py::Boolean(advancedShapeContent));
Py::Module shapecontent(module, true);

View File

@@ -125,7 +125,7 @@ private:
int goBOPSingleCheck(const TopoDS_Shape &shapeIn, ResultEntry *theRoot, const QString &baseName,
const Message_ProgressScope& theScope);
#endif
void buildShapeContent(const QString &baseName, const TopoDS_Shape &shape);
void buildShapeContent(App::DocumentObject *pObject, const QString &baseName, const TopoDS_Shape &shape);
ResultModel *model;
QTreeView *treeView;
QLabel *message;