What's new

Addressing sketch objects

eendrigo

Member
Addressing sketch objects

Hi all!

Struggling hardly with the not so well documented API...

While we understand how to add sketch figures after we've found this piece of code:

IADSketchPointPtr AddSketchPoint (
double XCoord,
double YCoord );
IADSketchLinePtr AddLine (
double X1,
double Y1,
double X2,
double Y2 );
IADSketchCirclePtr AddCircle (
double XCenter,
double YCenter,
const _variant_t & Radius );
IADSketchCircularArcPtr AddCircularArcByCenterStartAngle (
double XCenter,
double YCenter,
double XStartPt,
double YStartPt,
double ArcAngle );
IADSketchCircularArcPtr AddCircularArcByCenterStartEnd (
double XCenter,
double YCenter,
double XStartPt,
double YStartPt,
double XEndPt,
double YEndPt );
IObjectCollectorPtr AddRectangle (
double Xlow,
double Ylow,
double Xhigh,
double Yhigh );
IADSketchBsplinePtr AddBspline (
int order,
int numCtlPoints,
SAFEARRAY * * pCtlPoints,
SAFEARRAY * * pKnotVector,
SAFEARRAY * * pWeights );
IADSketchCircularArcPtr AddCircularArcBy3Points (
double XCenter,
double YCenter,
double XStartPt,
double YStartPt,
double XEndPt,
double YEndPt );
IADSketchCircularArcPtr AddCircularArc (
double XCenter,
double YCenter,
double XStartPt,
double YStartPt,
double ArcAngle );


we still do not know how to address sketch figures via the API. We wrote the following code, but do not know how to go on. The critical point is indicated by the ???. How can we refer to the specific geometric object (point, line, arc...) with its parameters and methods?

IADSketchFiguresPtr iFigures=iSketch->GetFigures();

if( iFigures != NULL) {

long nFigures=iFigures->GetCount();

for( long nIndex=0; nIndex<nFigures; nIndex++) {

IADSketchFigurePtr iFigure=iFigures->Item( nIndex);
int nFigureType=iFigure->GetType();

/*
enum ADObjectType
{
AD_UNKNOWN = -1,
AD_ROOT = 1,
AD_REPOSITORY = 2,
AD_FOLDER = 3,
AD_FOLDER_ITEM = 4,
AD_VERSION = 5,
AD_SESSION = 6,
AD_TEAM = 7,
AD_ROLE = 8,
AD_USER = 9,
AD_PARAMETER = 10,
AD_OCCURRENCE = 11,
AD_DESIGN_POINT = 12,
AD_DESIGN_AXIS = 13,
AD_DESIGN_PLANE = 14,
AD_TOPOLOGY = 15,
AD_SKETCH = 16,
AD_SKETCH_FIGURE = 17,
AD_PART_FEATURE = 18,
AD_GEOMETRY = 19,
AD_DESIGN_SURFACE = 20,
AD_DIMENSION = 21,
AD_3D_SKETCH = 22,
AD_ASSEMBLY_CONSTRAINT = 23,
AD_CONFIGURATION = 24
};
*/

int nFigureGeometricType=iFigure->GetFigureType();

if( nFigureGeometricType == AD_LINE) {

??? IADSketchLine
}
/*
enum ADGeometryType
{
AD_LINE = 0,
AD_CIRCLE = 1,
AD_ELLIPSE = 2,
AD_BSPLINE = 3,
AD_CIRCULAR_ARC = 5,
AD_ELLIPTICAL_ARC = 6,
AD_PLANE = 7,
AD_CYLINDER = 8,
AD_CONE = 9,
AD_SPHERE = 10,
AD_TORUS = 11,
AD_POINT = 12,
AD_BSURF = 13
};
*/
}

}


Any hints?

Thanks for your help,

Ezio

:x
 

alexfranke

Senior Member


If the IAD_SKETCH_FIGURE is of FigureType AD_LINE, it'll implement IADSketchLine... so, something like this?

Code:
if ( AD_LINE == iFigure->GetFigureType() )
{
  IADSketchPoint start = ( (IADSketchLine)iFigure ).Start;
  // .... 
}

Hope this helps...
-Alex
 

eendrigo

Member
ADDRESSING SKETCH OBJECTS

Hi Frank,

this is the correct code :

if( nFigureGeometricType == AD_LINE) {

IADSketchLinePtr iLine;
iFigure->QueryInterface( &iLine);

//IADSketchLinePtr iLine=((IADSketchLinePtr)iFigure);

if( iLine) {

IADSketchPointPtr iStart=iLine->GetStart();
double rX=iStart->GetX();
double rY=iStart->GetY();
double rLunghezza=iLine->GetLength();


}

Thank you

:lol:
 
Top