Drawing a random object

Use this forum to ask questions about how to do things in dxflib.

Moderator: andrew

Post Reply
laser
Registered Member
Posts: 1
Joined: Tue Dec 02, 2008 12:25 pm

Drawing a random object

Post by laser » Tue Dec 02, 2008 2:25 pm

Hi,

I've just begun using this library. Starting with your example, I can draw straight lines and points.
However, with a given set of points, what function do I have to use if I want to connect them ?
I thought about using spline or polyline but I can't get it work.

Can you please give me an example ?
Thanks.

bonsalty
Newbie Member
Posts: 9
Joined: Tue Jun 09, 2009 2:54 pm

Post by bonsalty » Wed Jun 10, 2009 10:31 am

Use polyline. polyline uses verteces.
example from my code:

dxf->writePolyline(*dw,
DL_PolylineData(NumberOfVertex,0,0,0),
DL_Attributes(......));

dxf->writeVertex(*dw,DL_VertexData( x,y,z,0);
dxf->writeVertex(*dw,DL_VertexData( x2,y2,z2,0);
dxf->writeVertex(*dw,DL_VertexData( x3,y3,z3,0);
.
.
.

dxf->writePolylineEnd(*dw);

nour
Newbie Member
Posts: 4
Joined: Mon Sep 14, 2009 6:18 pm

dxf->writePolyline problem

Post by nour » Mon Sep 14, 2009 6:30 pm

hello am trying to use the dxflib to extract the lwolyline form a dxf file.
so i can extrude it later on.
I saved the vertices of the polyline in an array
but i cant draw the polyline am not sure what would my problem be.
am new to dxflib
my code looks exactly as the one u mentioned here .
and i used a while loop to get all the vertices from my array
is there any paper where i can read more about the dxf polyline !
anyhelp would be appreciated
thank you
nour

-------------------------------------
dxf->writePolyline(*dw,
DL_PolylineData(maxvert,0,0,0),
DL_Attributes("mainlayer", 256, -1, "BYLAYER"));
while(i<maxvert)
{
dxf->writeVertex(*dw,DL_VertexData(vert[i*3], vert[i*3+1], vert[i*3+2],0));
i++;
}
dxf->writePolylineEnd(*dw);

bonsalty
Newbie Member
Posts: 9
Joined: Tue Jun 09, 2009 2:54 pm

Your failure...

Post by bonsalty » Tue Sep 15, 2009 1:17 pm

Of course you have to call Polyline in the entity section. The reason it doesnt work might be that you use incorrect parameters in DL_PolylineData.
I will add my code.


Im using my own wrapper class. I defined the entities(line,polyline,hatch,circle,etc) each as a class, and for each class type there is a vector, that holds the entities I draw.
For instance the class polyline has variables like layer name,color,line width and of course the coordinates for each vertex.

Here is my code for the polyline caddrawing:

for (int i=0;i<polylines.size();i++){ // for each polyline

DL_PolylineData(polylines.NumOfVertex,0,0,0), DL_Attributes(polylines.Layer.Name, polylines.Color, polylines.Width,polylines.Ltype.Name));

for (int j=0;j<polylines.NumOfVertex;j++){ //for each vertex in poly
dxf->writeVertex(*dw,DL_VertexData(
polylines.Polyline.GetX(j),
polylines.Polyline.GetY(j),
polylines.Polyline.GetZ(j),0));

} //end for each vertex


dxf->writePolylineEnd(*dw);



}//end for each polyline


So: polylines is the vector of my polyline class.
You have to know how many verteces each polyline consist of.
I store this number in polylines[i].NumOfVertex
In DL_PolylineData( polylines[i].NumOfVertex, ... ) you have to define how many verteces you are using and you must call
dxf->writeVertex(...) exactly the same time, otherwise it wont display anything.

I hope it was helpfull

nour
Newbie Member
Posts: 4
Joined: Mon Sep 14, 2009 6:18 pm

thank you for the reply

Post by nour » Wed Sep 16, 2009 3:00 pm

i'll check my code again I found that it writes something but its not giving me the results i wanted.
am using dxf files that i created using visio.
but when import them to maya nothing appears may b also I have a problem in my original dxf files !

do you know if its possible to apply extrusion on this polyline ?!
i mean converting the lwpolyline to 3D polyline?

bonsalty
Newbie Member
Posts: 9
Joined: Tue Jun 09, 2009 2:54 pm

Post by bonsalty » Thu Sep 17, 2009 2:44 pm

Are you able to draw anything else?
If not, then this is not the problem.
This polyline is 3d, you dont have to convert, since it has a Z coordinate.

nour
Newbie Member
Posts: 4
Joined: Mon Sep 14, 2009 6:18 pm

thnx for your response

Post by nour » Thu Sep 17, 2009 2:58 pm

yes its has the z coordinate ! and i can draw the extracted polyline
may b with some wrong coordinates but i can work on that and i tested writePoint and writeline both works fine
but i was thinking of extracting this polyline and extruding it.
as its polyline and has no width or thickness am not sure how to do that am using maya and never worked with 3D ! its a bit confusing

any ideas !

bonsalty
Newbie Member
Posts: 9
Joined: Tue Jun 09, 2009 2:54 pm

Post by bonsalty » Thu Sep 17, 2009 3:17 pm

I guess I know whats your problem, the linewidth is incorrect.

linetype should/can be "BYLAYER", "SOLID", "DOT" etc

line width can be (means 1/100 mm) :

-3;
0;
5;
9;
13;
15;
18;
20;
25;
30;
35;
40;
50;
60;
70;
80;
90;
100;
120;
140;
200;

Otherwise it will fail!

nour
Newbie Member
Posts: 4
Joined: Mon Sep 14, 2009 6:18 pm

will try to change the type

Post by nour » Thu Sep 17, 2009 3:22 pm

i will try to change the type to solid !
and the line width is set to -1 always what does that mean ?!
where can i find about these parameters more ?

When i change to solid i get error reading file when i try to import it to maya.

Do u know what's the difference between DXF_DC, DXF_FBX

bonsalty
Newbie Member
Posts: 9
Joined: Tue Jun 09, 2009 2:54 pm

Post by bonsalty » Fri Sep 18, 2009 10:22 am

-3 Its the deafult width, -1 no idea but I think you can find it in the FAQ.

Try to change linetype to BYLAYER

Post Reply

Return to “dxflib 'How Do I' Questions”