Page 1 of 1
calculate area by selecting specified area from polyline
Posted: 24 Jan 2017, 21:09
by Neeha
Hello
I am using editordemo in my project . I am opening an dxf image in editing mode.
Now i am selecting some region by using polyline.
how can i calculate polyline length, width and also area of seleted part of that image.
help me!!!!
Re: calculate area by selecting specified area from polyline
Posted: 25 Jan 2017, 15:28
by support
Hello Neeha,
To calculate a width, height and area of the region bounded by a closed rectangular polyline, you can use
CADPolyLine.Box.Width and
CADPolyLine.Box.Height properties:
Code: Select all
CADPolyLine polyLine;
...
double rectArea = polyLine.Box.Width * polyLine.Box.Height;
Mikhail
Re: calculate area by selecting specified area from polyline
Posted: 25 Jan 2017, 21:27
by Neeha
thanks for the code.
But please also tell me how and where to write code.
Re: calculate area by selecting specified area from polyline
Posted: 25 Jan 2017, 21:37
by support
please also tell me how and where to write code
It depends on the logic of your application.
Mikhail
Re: calculate area by selecting specified area from polyline
Posted: 25 Jan 2017, 21:39
by Neeha
Hello
I want to implement it in editor demo
where already an option "add new poly" is written .
Re: calculate area by selecting specified area from polyline
Posted: 30 Jan 2017, 19:06
by support
Neeha,
The EditorDemo project uses the
EntitiesCreator class which creates entities automatically and doesn't expose CADEntity derivatives during creation of entities. However, you can try to find the last added polyline by using a
CADEntityCollection.FindLast method with the following predicate:
Code: Select all
Predicate<CADEntity> p = new Predicate<CADEntity>(ent => ent.EntType == EntityType.Polyline);
The FindLast method may be called in EndAddEntity method as shown below.
Code: Select all
public void EndAddEntity(bool val)
{
if(curAddEntityType != CreatorType.Undetected)
{
SetAddEntityMode(curAddEntityType);
SetEnableChecked();
ChangeControlState();
CADEntity ent = entCreator.Image.Converter.Entities.FindLast(p);
CADPolyLine polyline = ent as CADPolyLine;
double rectArea = polyline.Box.Width * polyline.Box.Height;
}
this.detMouseDown = val;
}
Mikhail
Re: calculate area by selecting specified area from polyline
Posted: 02 Feb 2017, 12:12
by Lilltina
support wrote:Hello Neeha,
To calculate a width, height and area of the region bounded by a closed rectangular polyline, you can use
CADPolyLine.Box.Width and
CADPolyLine.Box.Height properties:
Code: Select all
CADPolyLine polyLine;
...
double rectArea = polyLine.Box.Width * polyLine.Box.Height;
Mikhail
Thank you Mikhail this was a pice of cake thanks to you!
Testa
dagens casino nu för att spela
Bästa sidorna i Sverige hittar du på
Sweden casino med bäst bonusar.
Spela på
alla casino på nätet och vinn stort!
Letar du efter ett
casino utan konto? Läs mer om hur du gör det här.
Spela på valfritt
casino kortspel.
Re: calculate area by selecting specified area from polyline
Posted: 02 Feb 2017, 19:42
by support
Lilltina,
You are welcome.
Mikhail
Re: calculate area by selecting specified area from polyline
Posted: 14 Feb 2017, 14:06
by Holmes2499
thanks for the code.
Gclub