Mod: Use new addObject<T>(...) using regex
This commit is contained in:
@@ -866,7 +866,7 @@ private:
|
||||
} else {
|
||||
throw Py::TypeError("Expects argument of type DocumentObject, Shape, or Geometry");
|
||||
}
|
||||
Part::Feature *pcFeature = static_cast<Part::Feature*>(pcDoc->addObject("Part::Feature", name));
|
||||
Part::Feature *pcFeature = pcDoc->addObject<Part::Feature>(name);
|
||||
// copy the data
|
||||
pcFeature->Shape.setValue(shape);
|
||||
pcFeature->purgeTouched();
|
||||
|
||||
@@ -103,8 +103,8 @@ int Part::ImportIgesParts(App::Document *pcDoc, const char* FileName)
|
||||
if (aShape.ShapeType() == TopAbs_SOLID ||
|
||||
aShape.ShapeType() == TopAbs_COMPOUND ||
|
||||
aShape.ShapeType() == TopAbs_SHELL) {
|
||||
App::DocumentObject* obj = pcDoc->addObject("Part::Feature", aName.c_str());
|
||||
static_cast<Part::Feature*>(obj)->Shape.setValue(aShape);
|
||||
auto* obj = pcDoc->addObject<Part::Feature>(aName.c_str());
|
||||
obj->Shape.setValue(aShape);
|
||||
}
|
||||
else {
|
||||
builder.Add(comp, aShape);
|
||||
@@ -114,8 +114,7 @@ int Part::ImportIgesParts(App::Document *pcDoc, const char* FileName)
|
||||
}
|
||||
if (!emptyComp) {
|
||||
std::string name = fi.fileNamePure();
|
||||
Part::Feature *pcFeature = static_cast<Part::Feature*>(pcDoc->addObject
|
||||
("Part::Feature", name.c_str()));
|
||||
auto* pcFeature = pcDoc->addObject<Part::Feature>(name.c_str());
|
||||
pcFeature->Shape.setValue(comp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ int Part::ImportStepParts(App::Document *pcDoc, const char* Name)
|
||||
//}
|
||||
|
||||
Part::Feature *pcFeature;
|
||||
pcFeature = static_cast<Part::Feature*>(pcDoc->addObject("Part::Feature", name.c_str()));
|
||||
pcFeature = pcDoc->addObject<Part::Feature>(name.c_str());
|
||||
pcFeature->Shape.setValue(aSolid);
|
||||
|
||||
// This is a trick to access the GUI via Python and set the color property
|
||||
@@ -167,7 +167,7 @@ int Part::ImportStepParts(App::Document *pcDoc, const char* Name)
|
||||
// name += ws->Model()->StringLabel(ent)->ToCString();
|
||||
//}
|
||||
|
||||
Part::Feature *pcFeature = static_cast<Part::Feature*>(pcDoc->addObject("Part::Feature", name.c_str()));
|
||||
Part::Feature *pcFeature = pcDoc->addObject<Part::Feature>(name.c_str());
|
||||
pcFeature->Shape.setValue(aShell);
|
||||
}
|
||||
|
||||
|
||||
@@ -1575,7 +1575,7 @@ Feature* Feature::create(const TopoShape& shape, const char* name, App::Document
|
||||
document = App::GetApplication().newDocument();
|
||||
}
|
||||
}
|
||||
auto res = static_cast<Part::Feature*>(document->addObject("Part::Feature", name));
|
||||
auto res = document->addObject<Part::Feature>(name);
|
||||
res->Shape.setValue(shape);
|
||||
res->purgeTouched();
|
||||
return res;
|
||||
|
||||
@@ -260,8 +260,7 @@ void CrossSections::apply()
|
||||
App::Document* doc = (*it)->getDocument();
|
||||
std::string s = (*it)->getNameInDocument();
|
||||
s += "_cs";
|
||||
Part::Feature* section = static_cast<Part::Feature*>
|
||||
(doc->addObject("Part::Feature",s.c_str()));
|
||||
auto* section = doc->addObject<Part::Feature>(s.c_str());
|
||||
section->Shape.setValue(comp);
|
||||
section->purgeTouched();
|
||||
}
|
||||
|
||||
@@ -165,8 +165,7 @@ DlgProjectionOnSurface::DlgProjectionOnSurface(QWidget* parent)
|
||||
}
|
||||
this->attachDocument(m_partDocument);
|
||||
m_partDocument->openTransaction("Project on surface");
|
||||
m_projectionObject = dynamic_cast<Part::Feature*>(
|
||||
m_partDocument->addObject("Part::Feature", "Projection Object"));
|
||||
m_projectionObject = m_partDocument->addObject<Part::Feature>("Projection Object");
|
||||
if (!m_projectionObject) {
|
||||
throw Base::ValueError(QString(tr("Can not create a projection object!!!")).toUtf8());
|
||||
}
|
||||
|
||||
@@ -606,7 +606,7 @@ void SectionCut::restoreVisibility()
|
||||
Part::Box* SectionCut::createBox(const char* name, const Base::Vector3f& size) // NOLINT
|
||||
{
|
||||
// create a box
|
||||
auto pcBox = dynamic_cast<Part::Box*>(doc->addObject("Part::Box", name));
|
||||
auto pcBox = doc->addObject<Part::Box>(name);
|
||||
if (!pcBox) {
|
||||
throw Base::RuntimeError(std::string("SectionCut error: ")
|
||||
+ std::string(name) + std::string(" could not be added\n"));
|
||||
@@ -785,7 +785,7 @@ Part::Box* SectionCut::createZBox(const Base::Vector3f& pos, const Base::Vector3
|
||||
|
||||
Part::Cut* SectionCut::createCut(const char* name)
|
||||
{
|
||||
auto pcCut = dynamic_cast<Part::Cut*>(doc->addObject("Part::Cut", name));
|
||||
auto pcCut = doc->addObject<Part::Cut>(name);
|
||||
if (!pcCut) {
|
||||
throw Base::RuntimeError(std::string("SectionCut error: ")
|
||||
+ std::string(name) + std::string(" could not be added\n"));
|
||||
@@ -1004,7 +1004,7 @@ std::vector<App::DocumentObject*> createLinks(App::Document* doc, const std::vec
|
||||
}
|
||||
newName += "_CutLink";
|
||||
|
||||
auto pcLink = dynamic_cast<App::Link*>(doc->addObject("App::Link", newName.c_str()));
|
||||
auto pcLink = doc->addObject<App::Link>(newName.c_str());
|
||||
if (!pcLink) {
|
||||
throw Base::RuntimeError("'App::Link' could not be added");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user