Node 2 is a real node in the STAAD.Pro model located at (1, 0, 0), and the GetNodeNumber method is correctly returning the node number that corresponds to the point coordinates (1,0,0). When I use GetNodeCoordinates(2, &x, &y, &z), I expect to get the same coordinates (1, 0, 0) but the method is returning (0, 0, 0) instead of (1, 0, 0). The code and output is as follows:
GetNodeNumber
GetNodeCoordinates(2, &x, &y, &z)
#include <iostream>#import "C:\Program Files\Bentley\Engineering\STAAD.Pro CONNECT Edition\STAAD\StaadPro.dll" named_guids
using namespace OpenSTAADUI;using namespace std;
namespace OSApp = OpenSTAADUI;
int main(){ OSApp::IOpenSTAADUIPtr OSAppPtr; OSApp::IOSGeometryUIPtr OSGeomPtr;
try { CoInitialize(NULL); HRESULT hr = OSAppPtr.CreateInstance(__uuidof(OSApp::OpenSTAAD));
hr = OSAppPtr.GetActiveObject(__uuidof(OSApp::OpenSTAAD));
OSGeomPtr = OSAppPtr->GetGeometry();
int Node2 = OSGeomPtr->GetNodeNumber(1.0, 0.0, 0.0); printf("Node number at (1,0,0) = %d\n", Node2); VARIANT x, y, z; VariantInit(&x); VariantInit(&y); VariantInit(&z); OSGeomPtr->GetNodeCoordinates(2, &x, &y, &z); printf("Node %d coordinates: (%f, %f, %f)\n", 2, V_R8(&x), V_R8(&y), V_R8(&z)); VariantClear(&x); VariantClear(&y); VariantClear(&z); } catch (_com_error& e) { _bstr_t bstrDescription = e.Description(); printf("COM Error! %s\n", bstrDescription); }
return 0;}
OUTPUT:
Node number at (1,0,0) = 2Node 2 coordinates: (0.000000, 0.000000, 0.000000)