MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / setPyObject

Method setPyObject

src/App/PropertyUnits.cpp:92–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92void PropertyQuantity::setPyObject(PyObject* value)
93{
94 // Set the unit if Unit object supplied, else check the unit
95 // and set the value
96
97 if (PyObject_TypeCheck(value, &(UnitPy::Type))) {
98 Base::UnitPy* pcObject = static_cast<Base::UnitPy*>(value);
99 Base::Unit unit = *(pcObject->getUnitPtr());
100 aboutToSetValue();
101 _Unit = unit;
102 hasSetValue();
103 }
104 else {
105 Base::Quantity quant = createQuantityFromPy(value);
106
107 if (quant.isDimensionless()) {
108 PropertyFloat::setValue(quant.getValue());
109 return;
110 }
111
112 if (_Unit != quant.getUnit()) {
113 throw Base::UnitsMismatchError("Not matching Unit!");
114 }
115
116 PropertyFloat::setValue(quant.getValue());
117 }
118}
119
120void PropertyQuantity::setPathValue(const ObjectIdentifier& /*path*/, const boost::any& value)
121{

Callers

nothing calls this directly

Calls 5

isDimensionlessMethod · 0.80
setValueFunction · 0.70
getValueMethod · 0.45
getUnitMethod · 0.45
setValueMethod · 0.45

Tested by

no test coverage detected