xdata with sds

Topics relating to AutoLisp and SDS.

Moderators: CMS Inc, avaernes

Post Reply
efernal
Valued Contributor
Posts: 28
Joined: Thu Jul 05, 2007 6:42 pm
Contact:

xdata with sds

Post by efernal » Sun Oct 28, 2007 6:04 am

need an example for insert xdata with xdata (-3 groupp)
there's nothing in ourbase.c
thanks in advance,
ef
efernal
Valued Contributor
Posts: 28
Joined: Thu Jul 05, 2007 6:42 pm
Contact:

Post by efernal » Sun Oct 28, 2007 6:06 am

sorry, 'Insert xdata with sds..'
ef
efernal
Valued Contributor
Posts: 28
Joined: Thu Jul 05, 2007 6:42 pm
Contact:

Post by efernal » Sun Oct 28, 2007 6:58 am

this works...

struct sds_resbuf *rb = NULL;

sds_regapp("TESTE");

rb = sds_buildlist(RTLB,
RTSTR, "(ENTMAKE (LIST (CONS 0 \"LINE\")",
RTSTR, "(CONS 10 (LIST 50.0 0.0 0.0))",
RTSTR, "(CONS 11 (LIST 100.0 0.0 0.0))",
RTSTR, "(LIST -3 (LIST \"TESTE\" (CONS 1040 1.0)))))",
RTLE,
0);

sds_retlist(rb);
sds_cmd(rb);
sds_relrb(rb);

But need other ways (in c, not c++)

ef
Danielm103
Valued Contributor
Posts: 52
Joined: Mon Aug 07, 2006 11:01 pm
Location: Albuquerque,NM,USA

Post by Danielm103 » Sun Oct 28, 2007 7:49 am

Both C and C++ use the same method of attaching Xdata to an object.
What you’re doing is sending lisp string to be evaluated.
You can send the DXF values directly.

Here is a sample, but provides no error checking.

Code: Select all

int Test(void)
{
    struct sds_resbuf *entlist = NULL;
    sds_regapp("TEST");
    sds_point point1 = { 0.0, 0.0, 0.0 };
    sds_point point2 = { 100.0, 100.0, 0.0 };
    entlist = sds_buildlist
    (
        RTDXF0,"line", 
        8, "0", 
        10, point1, 
        11, point2,
        -3, 
        1001, "TEST",
        1000, "A String",
        1040, 1.0,
        1071, 1237,
        RTNONE
    );    
    sds_entmake(entlist);
    sds_relrb(entlist);
    return (RSRSLT);
}
efernal
Valued Contributor
Posts: 28
Joined: Thu Jul 05, 2007 6:42 pm
Contact:

xdata

Post by efernal » Sun Oct 28, 2007 3:54 pm

thank you very much, Daniel.
it works perfectly...

e.fernal
efernal
Valued Contributor
Posts: 28
Joined: Thu Jul 05, 2007 6:42 pm
Contact:

xdata + code

Post by efernal » Sun Oct 28, 2007 4:11 pm

;; this is the function where xdata was needed
;; draw 2 or 3 lines (pipe + center line)
;; it uses xdata for inserting components after...

int tpipe2(sds_real width, int draw_center)
{
sds_point p0, p1, p2, pa, pb, pc, pd, pe, pf, pg, ph, i1, i2;
sds_real a1, a2, angulo = (PI * 0.5);
struct sds_resbuf *rb = NULL;
sds_real lista1[2][3], lista2[4][3], lista3[2][3];
short f1 = 0, f2 = 0;
char layer[6] = "Eix";

if(sds_tblsearch("APPID", "Cobrapi_Eixos", 0) == NULL)
sds_regapp("Cobrapi_Eixos");

if
(!strcmp(pipe_2, "___01")) strcat(layer, "01");
else if
(!strcmp(pipe_2, "___02")) strcat(layer, "02");
else if
(!strcmp(pipe_2, "___03")) strcat(layer, "03");
else if
(!strcmp(pipe_2, "___04")) strcat(layer, "04");
else
strcat(layer, "01");

if(sds_getpoint(NULL, "\n-> Forneça ponto : ", p0) != RTNORM)
{
sds_printf("\n-> Ponto inicial não fornecido...");
sds_retvoid();
return(0);
}
if(sds_getpoint(p0, "\n-> Próximo ponto : ", p1) != RTNORM)
{
sds_printf("\n-> Segundo ponto não fornecido...");
sds_retvoid();
return(0);
}

lista1[0][0] = p0[0];
lista1[0][1] = p0[1];
lista1[0][2] = p0[2];

lista1[1][0] = p1[0];
lista1[1][1] = p1[1];
lista1[1][2] = p1[2];

if(draw_center == 1)
{
if (sds_tblsearch("LTYPE", "CENTER", 0) == NULL)
sds_command(RTSTR, "_.LINETYPE",
RTSTR, "_LOAD",
RTSTR, "CENTER",
RTSTR, "ICADISO.LIN",
RTSTR, "",
RTNONE);

rb = sds_buildlist(RTDXF0, "LINE",
6, "CENTER",
8, layer,
10, p0,
11, p1,
-3,
1001, "Cobrapi_Eixos", 1040, width,
0);
sds_entmake(rb);
sds_relrb(rb);
}
else
sds_grdraw(p0, p1, 6, 0);

while(sds_getpoint(p1, "\n-> Ponto seguinte : ", p2) == RTNORM)
{
a1 = sds_angle(p0, p1);
a2 = sds_angle(p1, p2);

sds_polar(p0, a1 + angulo, width, pa);
sds_polar(p1, a1 + angulo, width, pb);
sds_polar(p0, a1 - angulo, width, pc);
sds_polar(p1, a1 - angulo, width, pd);

sds_polar(p1, a2 + angulo, width, pe);
sds_polar(p2, a2 + angulo, width, pf);
sds_polar(p1, a2 - angulo, width, pg);
sds_polar(p2, a2 - angulo, width, ph);

sds_inters(pa, pb, pe, pf, 0, i1);
sds_inters(pc, pd, pg, ph, 0, i2);

if (f1 == 1)
{
pa[0] = lista2[0][0];
pa[1] = lista2[0][1];
pa[2] = lista2[0][2];

pc[0] = lista2[2][0];
pc[1] = lista2[2][1];
pc[2] = lista2[2][2];
}

rb = sds_buildlist(RTDXF0, "LINE",
6, "ByLayer",
8, pipe_1,
10, pa,
11, i1,
0);
sds_entmake(rb); sds_relrb(rb);

rb = sds_buildlist(RTDXF0, "LINE",
6, "ByLayer",
8, pipe_1,
10, pc,
11, i2,
0);
sds_entmake(rb); sds_relrb(rb);

lista2[0][0] = i1[0];
lista2[0][1] = i1[1];
lista2[0][2] = i1[2];

lista2[1][0] = pf[0];
lista2[1][1] = pf[1];
lista2[1][2] = pf[2];

lista2[2][0] = i2[0];
lista2[2][1] = i2[1];
lista2[2][2] = i2[2];

lista2[3][0] = ph[0];
lista2[3][1] = ph[1];
lista2[3][2] = ph[2];

lista3[0][0] = p1[0];
lista3[0][1] = p1[1];
lista3[0][2] = p1[2];

lista3[1][0] = p2[0];
lista3[1][1] = p2[1];
lista3[1][2] = p2[2];

f1 = 1;

if(draw_center == 1)
{
rb = sds_buildlist(RTDXF0, "LINE",
6, "CENTER",
8, layer,
10, p1,
11, p2,
-3,
1001, "Cobrapi_Eixos",
1040, width,
0);
sds_entmake(rb);
sds_relrb(rb);
}
else
sds_grdraw(p1, p2, 6, 0);


p0[0] = p1[0];
p0[1] = p1[1];
p0[2] = p1[2];

p1[0] = p2[0];
p1[1] = p2[1];
p1[2] = p2[2];

} // while

if (f1 == 1)
{
pa[0] = lista2[0][0];
pa[1] = lista2[0][1];
pa[2] = lista2[0][2];

pb[0] = lista2[1][0];
pb[1] = lista2[1][1];
pb[2] = lista2[1][2];

rb = sds_buildlist(RTDXF0, "LINE",
6, "ByLayer",
8, pipe_1,
10, pa,
11, pb,
0);
sds_entmake(rb); sds_relrb(rb);

pa[0] = lista2[2][0];
pa[1] = lista2[2][1];
pa[2] = lista2[2][2];

pb[0] = lista2[3][0];
pb[1] = lista2[3][1];
pb[2] = lista2[3][2];

rb = sds_buildlist(RTDXF0, "LINE",
6, "ByLayer",
8, pipe_1,
10, pa,
11, pb,
0);
sds_entmake(rb);
sds_relrb(rb);

}
else
{
sds_polar(p0, sds_angle(p0, p1) + angulo, width, pa);
sds_polar(p1, sds_angle(p0, p1) + angulo, width, pb);
sds_polar(p0, sds_angle(p0, p1) - angulo, width, pc);
sds_polar(p1, sds_angle(p0, p1) - angulo, width, pd);

rb = sds_buildlist(RTDXF0, "LINE",
6, "ByLayer",
8, pipe_1,
10, pa,
11, pb,
0);

sds_entmake(rb); sds_relrb(rb);

rb = sds_buildlist(RTDXF0, "LINE",
6, "ByLayer",
8, pipe_1,
10, pc,
11, pd,
0);

sds_entmake(rb); sds_relrb(rb);
}

sds_retvoid();
return(0);
}
Post Reply