How to draw with poliline
Moderators: SDS, support, admin
-
- Posts: 19
- Joined: 03 Dec 2008, 20:04
How to draw with poliline
Hi,
I try to draw an image in CADImport. Now I stack with the PolyLine. I have DPointCollection and I don't know how to pass it to Polyline in order to draw some segment of my part. Can you give me an example of how I can do this?
I am a New user, I looked at the codes of Viewer and Editor. Not very self-explanative, but can be understandable for the newbee like me. More difficult is the task to ajust the code for my own needs. Every help will be appreciated.
Elena
I try to draw an image in CADImport. Now I stack with the PolyLine. I have DPointCollection and I don't know how to pass it to Polyline in order to draw some segment of my part. Can you give me an example of how I can do this?
I am a New user, I looked at the codes of Viewer and Editor. Not very self-explanative, but can be understandable for the newbee like me. More difficult is the task to ajust the code for my own needs. Every help will be appreciated.
Elena
Re: How to draw with poliline
Hello Elena,
Please try the following code (it is based on Viewer demo):
Sergey.
Please try the following code (it is based on Viewer demo):
Code: Select all
private void btnDuplicatePolyline_Click(object sender, System.EventArgs e)
{
if(this.cadImage == null)
{
return;
}
this.cadImage.UseDoubleBuffering = false;
int entCount = this.cadImage.Converter.GetCounts(CADImport.FaceModule.ConvSection.Entities);
for (int i=0;i<entCount;i++)
{
CADEntity ent = this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities[i];
if (ent is CADPolyLine)
{
CADPolyLine entPolyline = ent as CADPolyLine;
CADPolyLine entPolylineDuplicate = new CADPolyLine();
entPolylineDuplicate.Closed = true;
entPolylineDuplicate.Color = Color.Azure;
entPolylineDuplicate.LineWeight = 1.4;
CADVertex entVert;
for (int j=0;j<entPolyline.Count;j++)
{
entVert = new CADVertex();
CADVertex tempVert = (CADVertex )entPolyline.Entities[j];
entVert.Point = new DPoint(tempVert.Point.X + 10, tempVert.Point.Y + 10, tempVert.Point.Z + 10);
entPolylineDuplicate.AddEntity(entVert);
}
entPolylineDuplicate.Closed = entPolyline.Closed;
entPolylineDuplicate.Loaded(this.cadImage.Converter);
this.cadImage.CurrentLayout.Entities.Add(entPolylineDuplicate);
this.cadImage.Converter.OnCreate(entPolylineDuplicate);
}
}
this.ResizeLayout();
}
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 19
- Joined: 03 Dec 2008, 20:04
Re: How to draw with poliline
Sergey,
thank you for your reply. It is very helpful, honestly.
At this point I have only one problem with drawing polylines. I am still not sure about adding arcs. I assume that the best thing about polyline is adding entities to it without thinking about coordinates, just using start/end points. For the CADArc things look different. I have to calculate start/end angles. Not very difficult part in simple task, but for drawing some complex parts it becomes quiet a problem with connecting points. Of course, I can override some functions to some extent, but I wanted to know first if there is a built-in functionality in CADImport that I can use for this purposes.
In other words, is there a way to add rounded entities to polyline\block...whatever using points, not angles?
Elena
thank you for your reply. It is very helpful, honestly.
At this point I have only one problem with drawing polylines. I am still not sure about adding arcs. I assume that the best thing about polyline is adding entities to it without thinking about coordinates, just using start/end points. For the CADArc things look different. I have to calculate start/end angles. Not very difficult part in simple task, but for drawing some complex parts it becomes quiet a problem with connecting points. Of course, I can override some functions to some extent, but I wanted to know first if there is a built-in functionality in CADImport that I can use for this purposes.
In other words, is there a way to add rounded entities to polyline\block...whatever using points, not angles?
Elena
Re: How to draw with poliline
Hello Elena,
We suppose that you need to create a polyline which contain arcs as segments. If it is true, it is necessary to use Bulge property of CADVertex object:
Sergey.
We suppose that you need to create a polyline which contain arcs as segments. If it is true, it is necessary to use Bulge property of CADVertex object:
Please try modified code we gave earlier:Bulge (optional; default is 0). The bulge is the tangent of one fourth the included angle for an arc segment, made negative if the arc goes clockwise from the start point to the endpoint. A bulge of 0 indicates a straight segment, and a bulge of 1 is a semicircle
Code: Select all
private void btnAdd3DFace_Click(object sender, System.EventArgs e)
{
if(this.cadImage == null)
{
this.cadImage = new CADImage();
this.cadImage.InitialNewImage();
this.cadImage.UseDoubleBuffering = false;
}
this.cadImage.UseDoubleBuffering = false;
CADPolyLine entPolyine = new CADPolyLine();
CADVertex entVert = new CADVertex();
entVert.Bulge = 0.1;
entVert.Point = new DPoint(100,100,100);
entPolyine.AddEntity(entVert);
entVert = new CADVertex();
entVert.Bulge = 0.3;
entVert.Point = new DPoint(50,100,10);
entPolyine.AddEntity(entVert);
entVert = new CADVertex();
entVert.Bulge = 0.5;
entVert.Point = new DPoint(100,50,50);
entPolyine.AddEntity(entVert);
entVert = new CADVertex();
entVert.Point = new DPoint(50,50,50);
entPolyine.AddEntity(entVert);
entPolyine.Color = Color.Red;
this.cadImage.Converter.OnCreate(entPolyine);
this.cadImage.Converter.Loads(entPolyine);
this.cadImage.Converter.Entities.Add(entPolyine);
this.cadPictBox.Invalidate();
}
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 19
- Joined: 03 Dec 2008, 20:04
Re: How to draw with poliline
Sergey, I tryed your example, it seems that it is exactly what I was looking for.
I still have a problem. When I try to change z coordinates from your example, nothing change in drawing. But changing X and Y coordinates change the image.
Can it be something wrong with my original parameters/mapping, for example, RectangleF? Which settings can influence 3D drawing?
Elena
I still have a problem. When I try to change z coordinates from your example, nothing change in drawing. But changing X and Y coordinates change the image.
Can it be something wrong with my original parameters/mapping, for example, RectangleF? Which settings can influence 3D drawing?
Elena
Re: How to draw with poliline
Elena, OX and OY axes are in the screen plane by definition. OZ axis goes inside of the space behind a monitor. That is why you can't see any changes when "playing" with Z coordinate.
Please try the following lines under separate button after adding entities by code posted on December,12th:
Sergey.
Please try the following lines under separate button after adding entities by code posted on December,12th:
Code: Select all
this.cadImage.Rotate(CADImport.Axes.Y, 90);
this.cadPictBox.Invalidate();
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 19
- Joined: 03 Dec 2008, 20:04
Re: How to draw with poliline
Sergey,
does your answer mean, that creating polylines with 3D coordinates I get a 2D representation of the drawing (Z-axis is outside the screen), but rotating the part around X and Y axices gives me the proper 3D representation? In other words I don't have to worry about calculating angles for drawing in isometry (right now I do and it takes a lot of time)?
does your answer mean, that creating polylines with 3D coordinates I get a 2D representation of the drawing (Z-axis is outside the screen), but rotating the part around X and Y axices gives me the proper 3D representation? In other words I don't have to worry about calculating angles for drawing in isometry (right now I do and it takes a lot of time)?
Re: How to draw with poliline
Elena,
We may definitely affirm that we get real 3D Polyline using code given on the 12 Dec 2008 post. And we are off the information what axactly angles you need to calculate for your drawing in isometry.
Sergy.
We may definitely affirm that we get real 3D Polyline using code given on the 12 Dec 2008 post. And we are off the information what axactly angles you need to calculate for your drawing in isometry.
Sergy.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 19
- Joined: 03 Dec 2008, 20:04
Re: How to draw with poliline
Sergey,
your answer is not very clear for me and maybe is too emotional. I don't ask you to calculate anything, sorry if my words can be interpreted that way.
I try to solve the same problem as other clients of yours in the forum do - finding an easiest way to represent 3D part. From your examples I didn't see much difference in giving Z-coordinates (Z-axis is behind the screen). Right now I draw 3D manually, calculating the angles of view, but I am absolutely confident that there is an easiest way to transform 2D (flat) drawing to 3D. I know, that my part has Z-coordinates that I can't see on the screen.
The question is simple - can it be done another, more "AutoCad" way, and how?
Elena
your answer is not very clear for me and maybe is too emotional. I don't ask you to calculate anything, sorry if my words can be interpreted that way.
I try to solve the same problem as other clients of yours in the forum do - finding an easiest way to represent 3D part. From your examples I didn't see much difference in giving Z-coordinates (Z-axis is behind the screen). Right now I draw 3D manually, calculating the angles of view, but I am absolutely confident that there is an easiest way to transform 2D (flat) drawing to 3D. I know, that my part has Z-coordinates that I can't see on the screen.
The question is simple - can it be done another, more "AutoCad" way, and how?
Elena
Re: How to draw with poliline
Elena,
Do you mean 3D modelling? If you do we do not have such functionality in the broad sense of the word.
Sergey.
Do you mean 3D modelling? If you do we do not have such functionality in the broad sense of the word.
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 19
- Joined: 03 Dec 2008, 20:04
Re: How to draw with poliline
Sergey,
drawing with polyline I met one more problem that I need your clarification.
In my drawing I need to emphasize some parts of it either with didfferent color or different line weight. Is it possible for polylines and how? I didn't find that answer in your examples.
Elena
drawing with polyline I met one more problem that I need your clarification.
In my drawing I need to emphasize some parts of it either with didfferent color or different line weight. Is it possible for polylines and how? I didn't find that answer in your examples.
Elena
Re: How to draw with poliline
Elena,
Unfortunately such functionality is unavailable.
Sergey.
Unfortunately such functionality is unavailable.
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support