Autodesk GIS Design Server
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
*Richard Horrocks [Autodesk]
Creating Polygons in AGDS 8.x using Object Rules
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
118 Views, 1 Replies
04-30-2004 12:55 PM
Here is the information on how to create topological polygons using
ObjectRules:
The following assumes that there are two classes, Centroid and Edge.
Centroid should have a 'polygon' graphic type and Edge can be any line
feature.
The centroid features can't currently be digitized using ObjecRules. They
can only be drafted in direct mode and thus, it is the application's
responsability to draft the centroid, collect the coordinates in a container
and pass it back to ObjectRules.
The application should have a local user event handler registered for an
event (say 'centroid_creation_handler' as specified in DOM). So you have to
include this event in your application
In the example the name of the container that the application has to pass
the drafting method to the DOM is 'ToPolyCentroidPt' .
The operation FormPolygon is what should be used. It should be invoked in
direct mode with the edge ids passed in the container. Please see the
documentation for use of FormPolygon.
Here is a scenario:
- Have a Create method in Centroid that creates the centroid feature
- Have a Create method in Edge that also creates a closed edge
- Have a method in Edge that creates a container and adds the edge id
to this container
- Have a Form method in Centroid that calls FormPolygon operation passing
the container.
Here an example using the classes "PropertyCent" (centroid) and
"PropertyEdge" (boundary)
PropertyEdge::create::action
Definition(create)
Drafting( , Freehand, Draw)
StoreEdge(Add, , vewPolygonStoreEdgeData, )
FeatureCode:
roperty
SetProperty(parcel)
GraphicType:
roperty
SetProperty(line_unltd)
Layer:
roperty
SetProperty(8)
Network:
roperty
SetProperty(8)
PropertyCent::Create::Action
Definition(create)
Attributes(Attributes, traditional, edit)
Macro(event centroid_creation_handler) //Calling the event in the
application.
Drafting(, Direct, Draw, ToPolyCentroidPt) //passing from the application
the container with the coordenate to place the centroid.
Form::action
FormPolygon(direct, Automatic, cancel, vewPolygonStoreEdgeData, , , )
Attributes::Attributes
DialogTitle(Attributes for %c)
TabTitle(Parcel)
TextField("PIN_NUMBER", "pin_number", False)
TextField("ADDRESS_NUMBER", "address_number", False)
TextField("ROAD_NAME", "road_name", False)
TextField("POSTAL_CODE", "postal_code", False)
TextField("OWNER", "owner", False)
FeatureCode:
roperty
SetProperty(parcel_c)
GraphicType:
roperty
SetProperty(polygon)
Layer:
roperty
SetProperty(8)
Network:
roperty
SetProperty(8)
This works in this way. You can draw the centroid or the edge in any order,
but when you draw the Edges, the feat_num of those will be stored in the
container 'vewPolygonStoreEdgeData' (you can use the name that you want),
and then when the edges and the centroid are already drawn, you have to call
to the method 'Form', that will create the topology between the centroid and
the Edges.
The operation 'FormPolygon' is only supported in direct mode, this means
that has to be used a container. Once that the operation is successful the
container is flushed, otherwise the feat_nums will stay in the container.
In the handler code :
MyHandler:
nEvent(ULONG count, vutDataItemType** ppItems, BSTR filter)
{
if (event_name.Compare("centroid_creation_handler") == 0)
{
vutErrorHistory error_history;
HRESULT hr = S_OK;
CAppObjectRules *rules_engine = NULL;
IAeOrDraftingDataPtr draft_data = NULL;
IAeOrCoordinateStringPtr coord_data = NULL;
IDispatchPtr container = NULL;
IAeOrCoord3DPtr coord_s = NULL;
AeOrContainerTypeConstants type(AeOrDraftingData);
bool result = false;
long coord_count = 0, i = 0;
ads_point ads_poly_center;
int rc;
// Get the rules engine
result = CSampleApp::GetOREngine(&rules_engine);
if(false == result)
{
error_history = vutErrorHistory(VUT_ERROR_EN_INVALID_VALUE,
"Can not get the rules engine in InvokeCreatePolyCenterDataEvent()");
goto error_handler;
}
try
{
// Check to see if the container exists. If not, we will create it.
if(!rules_engine->ContainerExists("ToPolyCentroidP t"))
{
// We need to create a container named acadDraftingData
hr = draft_data.CreateInstance("AEObjectRules.AeOrDraft ingData");
if (FAILED(hr)) throw _com_error(hr);
// Attach it to the container
draft_data->put_ContainerName(_bstr_t("ToPolyCentr oidPt"));
// Attached the container to the rules engine
rules_engine->AddContainer(draft_data);
}
// Retrieve the drafting data from the rules engine
rules_engine->GetContainer("ToPolyCentroidPt", type, &container);
// Check to see if we get the valid container
if(NULL == container)
{
error_history = vutErrorHistory(VUT_ERROR_EN_INVALID_VALUE,
"Can not get the container in InvokeCreatePolyCenterDataEvent()");
goto error_handler;
}
// Query the drafting data interface
hr = container.QueryInterface(__uuidof(IAeOrDraftingDat a),
(void**)&draft_data);
if (FAILED(hr)) throw _com_error(hr);
// Get the point from AutoCAD
rc = acedGetPoint(NULL, "Pick a center point", ads_poly_center);
if (RTNORM == rc)
{
// Get the coord string
coord_data = draft_data->GetCoordinateString();
if(NULL == coord_data)
{
error_history = vutErrorHistory(VUT_ERROR_EN_INVALID_VALUE,
"Can not get the CoordinateString in InvokeCreatePolyCenterDataEvent()");
goto error_handler;
}
coord_count = coord_data->GetCount();
if(0 != coord_count)
{
// Remove all elements
coord_data->Clear();
}
// Create a start coord object
hr = coord_s.CreateInstance(__uuidof(AeOrCoord3D));
if (FAILED(hr)) throw _com_error(hr);
coord_s->PutX(ads_poly_center);
coord_s->PutY(ads_poly_center);
// Set the value
coord_data->Add(coord_s);
}
}
catch (_com_error e)
{
error_history = vutErrorHistory(e.Error(), (const char *)e.Description());
goto error_handler;
}
}
return error_history;
}
-------------------------------------------------- --------------------------
-------------------
Re: Creating Polygons in AGDS 8.x using Object Rules
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-08-2004 06:34 AM in reply to:
*Richard Horrocks [Autodesk]
how i can draw center line of polyline

