How to extract polylines from surface contours

How to extract polylines from surface contours

Anonymous
Not applicable
1,669 Views
3 Replies
Message 1 of 4

How to extract polylines from surface contours

Anonymous
Not applicable
I have gotten hold of a COM pointer to an AeccSurfaceContour object, and also the object's ContourEntities stored in a VARIANT array (of VT_I4's, I presume).

However, if I try to access the elements in the array (using SafeArrayAccessData) and convert them to AcDbObjectIds by doing the following:

AcDbObjectId objId;
objId.setFromOldId (array);//presume 'i' is an index into the array
bool isIdValid = objId.isValid();

then isIdValid is false and hence when I try to use it in functions like AcAxGetIUnknownOfObject () or acdbOpenObject(), they return with an error and an unhandled exception, respectively.

What is stored in the VARIANT array and how do I use the values to get hold of the polylines that represent the contours?

Rasmus Bugge
0 Likes
1,670 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Hi Rasmus,
The Contours collection of a TinSurface are strictly polylines that are used
to DEFINE the surface. If none were used due to the surface being defined by
Points & Breaklines then the collection will be empty.

To get the polylines used to display the resulting surface, first you must
have 2009. Second, the TinSurface object in 2009 has an ExtractContour
method which allows you to specify a range of elevations, Major Minor or
User Defined Contours, and what View to extract. I believe this is what you
are looking for.

HTH,
Jeff

"Rasmus Bugge" wrote in message news:5979220@discussion.autodesk.com...
I have gotten hold of a COM pointer to an AeccSurfaceContour object, and
also the object's ContourEntities stored in a VARIANT array (of VT_I4's, I
presume).

However, if I try to access the elements in the array (using
SafeArrayAccessData) and convert them to AcDbObjectIds by doing the
following:

AcDbObjectId objId;
objId.setFromOldId (array);//presume 'i' is an index into the array
bool isIdValid = objId.isValid();

then isIdValid is false and hence when I try to use it in functions like
AcAxGetIUnknownOfObject () or acdbOpenObject(), they return with an error
and an unhandled exception, respectively.

What is stored in the VARIANT array and how do I use the values to get hold
of the polylines that represent the contours?

Rasmus Bugge
0 Likes
Message 3 of 4

Anonymous
Not applicable
Hi,

Thanks for your reply.Yes, I have also realized that ExtractContour is the function to use...However, one question remains (as I use C++): What type is the VARIANT*? Is it a VT_VOID | VT_ARRAY? And am I supposed to cast from VOID to AcDbEntity*?

Rasmus Bugge
0 Likes
Message 4 of 4

Anonymous
Not applicable
Case closed.
0 Likes