py3: Part: App: gathering commits relevant for Mod/Part/App

This commit is contained in:
looooo
2017-03-01 17:10:46 +01:00
parent d5e9afa52b
commit 275db827aa
12 changed files with 130 additions and 37 deletions

View File

@@ -257,8 +257,11 @@ PyObject* AttachEnginePy::getModeInfo(PyObject* args)
}
Py::Dict ret;
ret["ReferenceCombinations"] = pyListOfCombinations;
#if PY_MAJOR_VERSION >= 3
ret["ModeIndex"] = Py::Long(mmode);
#else
ret["ModeIndex"] = Py::Int(mmode);
#endif
try {
Py::Module module(PyImport_ImportModule("PartGui"),true);
if (!module.hasAttr("AttachEngineResources")) {
@@ -269,7 +272,11 @@ PyObject* AttachEnginePy::getModeInfo(PyObject* args)
Py::Callable method(submod.getAttr("getModeStrings"));
Py::Tuple arg(2);
arg.setItem(0, Py::String(this->getAttachEnginePtr()->getTypeId().getName()));
#if PY_MAJOR_VERSION >= 3
arg.setItem(1, Py::Long(mmode));
#else
arg.setItem(1, Py::Int(mmode));
#endif
Py::List strs = method.apply(arg);
assert(strs.size() == 2);
ret["UserFriendlyName"] = strs[0];
@@ -342,8 +349,13 @@ PyObject* AttachEnginePy::getRefTypeInfo(PyObject* args)
AttachEngine &attacher = *(this->getAttachEnginePtr());
eRefType rt = attacher.getRefTypeByName(typeName);
Py::Dict ret;
#if PY_MAJOR_VERSION >= 3
ret["TypeIndex"] = Py::Long(rt);
ret["Rank"] = Py::Long(AttachEngine::getTypeRank(rt));
#else
ret["TypeIndex"] = Py::Int(rt);
ret["Rank"] = Py::Int(AttachEngine::getTypeRank(rt));
#endif
try {
Py::Module module(PyImport_ImportModule("PartGui"),true);
@@ -354,7 +366,11 @@ PyObject* AttachEnginePy::getRefTypeInfo(PyObject* args)
Py::Object submod(module.getAttr("AttachEngineResources"));
Py::Callable method(submod.getAttr("getRefTypeUserFriendlyName"));
Py::Tuple arg(1);
#if PY_MAJOR_VERSION >= 3
arg.setItem(0, Py::Long(rt));
#else
arg.setItem(0, Py::Int(rt));
#endif
Py::String st = method.apply(arg);
ret["UserFriendlyName"] = st;
} catch (Py::Exception& e) {