高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】help me. complex linetype problem
help me. complex linetype problem.
please help me. complex linetype problem.
hi.
i got a problem in autocad dwg save program.
this program uses a complex linetype in directdwg 1.11(dd)
after i had created a several of complex linetypes using dd, and created a autocad dwg file(version 2004) using dd.
however, wasn't displayed in autocad 2004 properly.
this dwg file has two lines with complex linetypes.
the struct of complex linetype is
*cdv000,vtype(conc) ----> v ----> v ---->
a,.9,[kc24,khcline.shx,s=.006],-.2,["v",standard,s=.2,x=.15,y=-.1],-.25,-.2
in .lin file.
before create this linetype, i had created a 'khcline.shx' textstyle(shape font). the 'khcline.shx' is shape file to be made from third party company.(currently, this shape file is widely using in autocad third party industry in korea. this file contains arrow style shapes.)
< below code is source code of the program. >
1) add styles.
void dbfiller::addstyles()
{
addstyle(pdb, "standard", textsize, xscale, priorsize, opblquing, "txt.shx", "", false, "", false, false, 0, 0);
...
addstyle(pdb, "khcline", textsize, xscale, priorsize, opblquing, "khcline.shx", "khcline", true, "", false, false, 0, 0);
}
2) add style.(shape file & font file)
void dbfiller::addstyle(oddbdatabaseptr pdb, odstring stylename, double textsize, double xscale, double priorsize, double obliquing, odstring filename, odstring bigfontname, bool isshapefile, const odstring& ttfacename, bool bold, bool italic, int charset, int pitchandfamily)
{
oddbtextstyletableptr pstyles;
pstyles = pdb->gettextstyletableid().safeopenobject(oddb::kforwr ite);
oddbtextstyletablerecordptr pstyle;
oddbobjectid existstyleid = pstyles->getat(stylename);
if(existstyleid.isnull())
pstyle = oddbtextstyletablerecord::createobject();
else
pstyle = existstyleid.safeopenobject(oddb::kforwrite);
if(pstyle.isnull())
return;
// name must be set before a table object is added to a table. the
// isshapefile flag must also be set (if true) before adding the object
// to the database.
pstyle->setname(stylename);
pstyle->setisshapefile(isshapefile);
// add the object to the table.
if(existstyleid.isnull())
pstyles->add(pstyle);
// set the remaining properties.
pstyle->settextsize(textsize);
pstyle->setxscale(xscale);
pstyle->setpriorsize(priorsize);
pstyle->setobliquingangle(obliquing);
pstyle->setfilename(filename);
pstyle->setbigfontfilename(bigfontname);
if (isshapefile)
{
pstyle->setpriorsize(22.45);
}
if (!ttfacename.isempty())
{
pstyle->setfont(ttfacename, bold, italic, charset, pitchandfamily);
}
}
3) add linetypes(mylinetypetable, mylinetype... are the linetype library symbol of my company.)
void dbfiller::addlinetypes(oddbdatabaseptr pdb)
{
oddblinetypetableptr ptable = pdb->getlinetypetableid().safeopenobject(oddb::kforwri te);
oddbtextstyletableptr ptexttable = pdb->gettextstyletableid().safeopenobject(oddb::kforwr ite);
mylinetypetable* pmytable = m_pmydb->getlinetypetable();
for(int i = 0; i < pmytable->getcount(); i++)
{
mylinetype* plinetype = pmytable->getat(i);
char szname[max_defstr];
strcpy(szname, plinetype->getname());
oddbobjectid existid = ptable->getat(szname);
oddblinetypetablerecordptr pentry = oddblinetypetablerecord::createobject();
odstring sdesc = plinetype->getdescript();
odstring sname = szname;
pentry->setname(sname);
// add the object to the table.
oddbobjectid id = ptable->add(pentry);
oddblinetypetablerecordptr plt = id.safeopenobject(oddb::kforwrite);
plt->setcomments(sdesc);
int ndash = plinetype->getpatterncount();
plt->setnumdashes(ndash);
double dlength = 0.;
for(int j = 0; j < ndash; j++)
{
mylinetypepattern* ppat = plinetype->getpatternobjat(j);
double ddash = ppat->getvalue();
dlength += fabs(ddash);
}
plt->setpatternlength(dlength);
// set patterns.
for(j = 0; j < ndash; j++)
{
mylinetypepattern* ppat = plinetype->getpatternobjat(j);
double ddash = ppat->getvalue();
plt->setdashlengthat(j, ddash);
odstring stextstyle = ppat->getsymbolstyle();
oddbobjectid id = ptexttable->getat(stextstyle);
plt->setshapestyleat(j, id); // not sure code!? (shape file or font file)
mypoint2d pt = ppat->getsymboloffset();
odgevector2d offset;
offset.x = pt.x, offset.y = pt.y;
plt->setshapeoffsetat(j, offset);
double dscale = ppat->getsymbolscale();
plt->setshapescaleat(j, dscale);
double dangle = ppat->getsymbolangle();
plt->setshaperotationat(j, dangle);
int inumber = ppat->getsymbolcode();
if(inumber >= 0) // if inumber is symbol code, inumber has a positive sign.
{
oduint16 shapenumber = inumber;
plt->setshapenumberat(j, shapenumber);
}
else
{
odstring text = ppat->getsymboltext();
plt->settextat(j, text);
}
}
}
}
4) save dwg file.
void _savedwgfile(...)
{
pod->writefile(&fb, oddb::kdwg, oddb::vac15, true /* save preview */);
}
how can i solve this complex linetype problem? please help me.
last edited by namosoft; 9th september 2004 at 07:15 pmfff">.
|