UG NX二次开发源码分享: 报告所有的表达式信息
UG NX二次开发源码分享: 报告所有的表达式信息void MyClass::do_it()
{
std::stringstream out;
ExpressionCollection *expcol = workPart->Expressions();
for (ExpressionCollection::iterator it = expcol->begin();
it != expcol->end();
it++)
{
Expression *expr = *it;
out.str(""); out.clear();
out << "\nExpression: " << expr->Tag() << std::endl;
out << "Name: " << expr->Name().GetText() << std::endl;
out << "Type: " << expr->Type().GetText() << std::endl;
out << "Description: " << expr->Description().GetText() << std::endl;
out << "Equation: " << expr->Equation().GetText() << std::endl;
std::string strType(expr->Type().GetText());
if ( strType.compare("Number") == 0 )
{
out << "Units: " << expr->Units()->Name().GetText() << std::endl;
out << "Number Value: " << expr->Value() << std::endl;
}
else if ( strType.compare("Boolean") == 0 )
out << "Boolean Value: " << expr->BooleanValue() << std::endl;
else if ( strType.compare("Integer") == 0 )
out << "Integer Value: " << expr->IntegerValue() << std::endl;
else if ( strType.compare("String") == 0 )
out << "String Value: " << expr->StringValue().GetText() << std::endl;
else if ( strType.compare("Point") == 0 )
out << "Point Value: " << expr->PointValue().X << "," << expr->PointValue().Y << "," << expr->PointValue().Z << std::endl;
else if ( strType.compare("Vector") == 0 )
out << "Vector Value: " << expr->VectorValue().X << "," << expr->VectorValue().Y << "," << expr->VectorValue().Z << std::endl;
else if( strType.compare("List") == 0 )
out << "List Value: " << expr->RightHandSide().GetText() << std::endl;
std::string strRHS(expr->RightHandSide().GetText());
std::string::size_type nPos = strRHS.find("//");
if( nPos != std::string::npos )
{
std::string strComment = strRHS.substr(nPos+2);
out << "Comment: " << strComment << std::endl;
}
if(expr->IsInterpartExpression())
{
NXString sPartName("");
NXString sExprName("");
expr->GetInterpartExpressionNames(&sPartName, &sExprName);
out << "IPE partName: " << sPartName.GetText() << std::endl;
out << "IPE exprName: " << sExprName.GetText() << std::endl;
}
print(out.str().c_str());
}
}
页:
[1]