几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-05-05, 12:01 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】hatching entities

hatching entities

hatching entities
hi all,
i've implemented hatching of entities. but i've a trouble. while trying to implement different hatching pattern, it failed to hatch the drawing.
i'ld like to know which all patterns are available for hatching.
i tried
phatch->setpattern(oddbhatch::kpredefined , "solid");
only this one is working.
but i found from the threads that, we can give the patterns which are available in 'acad.pat' file. but when i gave other patterns like
angle, ansi31, ansi32, ansi33, ansi34, etc, its not hatching at all.
so i want to know whether there is any predefined patterns available other than 'solid'.
thanks in advance for u'r replys
thanks & regards,
rajesh parameswaran

rajuinnet
# 23rd august 2004, 06:50 am

moderator join date: mar 2002
posts: 2,994
if acad.pat is available you can use hatch patterns from it.
hatch pattern manager will try to access acad.pat or acadiso.pat (english/metric) to load specified predefined pattern (it will call findfile() to locate it.
if you get empty hatches probably dd failed to access acad.pat or hatch scale is too large.
btw, odwriteex contains code illustrating different patterns usage.
sergey slezkin

sslezkin
# 23rd august 2004, 11:36 pm

registered user join date: jul 2004
location: india
posts: 82

quote:
originally posted by sergey slezkin
if acad.pat is available you can use hatch patterns from it.
hatch pattern manager will try to access acad.pat or acadiso.pat (english/metric) to load specified predefined pattern (it will call findfile() to locate it.
if you get empty hatches probably dd failed to access acad.pat or hatch scale is too large.
btw, odwriteex contains code illustrating different patterns usage.
hi sergey,
thank you for u'r reply. i've a better look on the sample project odwriteex. but it seems to be little bit confused. so here is the code, which i wrote for hatching the polylines.
kindly have a look and say whether is this the right way i'm doing.
if(pchildobj->iskindof(oddbpolyline::desc()))
{
oddbpolylineptr pchildobjpoly2d = pchildobj;
try
{
phatch = oddbhatch::createobject();
whitehatchid = pmainblock->appendoddbentity(phatch);
phatch->setassociative(true);
phatch->setcolorindex( k % 15 );
phatch->setpattern(oddbhatch::kpredefined, "angle");
phatch->sethatchstyle(oddbhatch::knormal);
vertexpts.resize(pchildobjpoly2d->numverts());
for (int i=0; i < pchildobjpoly2d->numverts(); i++)
{
pchildobjpoly2d->getpointat((unsigned int)i,
ptvertex);
vertexpts[i].set(ptvertex.x,ptvertex.y);
}
phatch->appendloop(oddbhatch::kexternal |
oddbhatch::kpolyline, vertexpts,vertexbulges);
}
catch(oderror &e)
{
str1.format("error: %s", e.description());
messagebox(str1);
}
}
thanks in advance,
regards,
rajesh parameswaran

rajuinnet
# 24th august 2004, 08:08 am

moderator join date: mar 2002
posts: 2,994
1. your hatch will not be associative because you have not specified entities it should be associated with. use appendloop() accepting objectid array to create associative hatch.
2. hatch will be invisible if hatch pattern manager fails to find acad.pat. it calls oddbhostappservices::findfile() to get full path to acad.pat. you can override findfile() in your oddbhostappservices inheritor.
another way it to specify hatch pattern (even predefined) manually instead of using acad.pat. see odwriteex sample.
sergey slezkin

sslezkin
# 25th august 2004, 11:36 pm

registered user join date: jul 2004
location: india
posts: 82

still hunting with hatching entities
quote:
originally posted by sergey slezkin
1. your hatch will not be associative because you have not specified entities it should be associated with. use appendloop() accepting objectid array to create associative hatch.
2. hatch will be invisible if hatch pattern manager fails to find acad.pat. it calls oddbhostappservices::findfile() to get full path to acad.pat. you can override findfile() in your oddbhostappservices inheritor.
another way it to specify hatch pattern (even predefined) manually instead of using acad.pat. see odwriteex sample.
hi sergey,
thanks for u'r response. as you said, i tried using appendloop() accepting objectid array to create associative hatch. i even tried the sample application odwriteex. i tried to draw a circle with angle hatch (associative).
the code is listed below...
oddbhatchptr phatch;
odgepoint3d point = odgepoint3d(120,120,0);
oddbdatabase *pdb = theapp.m_pdb;
oddbblocktablerecordptr pblock = pdb->getmodelspaceid().safeopenobject(oddb::kforwrite) ;
phatch = oddbhatch::createobject();
oddbobjectid hatchid = pblock->appendoddbentity(phatch);
phatch->setassociative(true);
phatch->setpattern(oddbhatch::kpredefined, "angle");
phatch->setpatternscale(0.5);
phatch->setpatternangle(0.5);
phatch->sethatchstyle(oddbhatch::knormal);
oddbobjectidarray loopids;
oddbcircleptr pcircle = oddbcircle::createobject();
loopids.push_back(pblock->appendoddbentity(pcircle));
odgepoint3d centerpt(point);
centerpt.x += 100*3.0/2.0;
centerpt.y -= 100;
pcircle->setcenter(centerpt);
pcircle->setradius(100*3.0/2.0);
phatch->appendloop(oddbhatch::kdefault, loopids);
m_pdevice->invalidate();
redrawwindow();
but even i tried this, its not hatching.. what may be the cause of the problem. is there anything wrong with the code.
is there any device specification for hatching. ? if so i'm able to hatch using solid hatches...so what could be the cause for the problem..
if u can show me the way of hatching with an example, it will be very helpful..
thanks in advance
thanks and regards,
rajesh parameswaran.
last edited by rajuinnet; 25th august 2004 at 11:38 pmfff">.

rajuinnet
# 26th august 2004, 06:00 am

moderator join date: mar 2002
posts: 2,994
try to add a hatch pattern to pattern manager manually like my_stars in odwriteex.
if you get visible hatch for it and invisible for predefined angle the reson is missing (not found) acad.pat or acadiso.pat file as i wrote in one of previous posts.
sergey slezkin

sslezkin
# 26th august 2004, 08:18 am

registered user join date: jul 2004
location: india
posts: 82

still problem with custom defiened hatches
quote:
originally posted by sergey slezkin
try to add a hatch pattern to pattern manager manually like my_stars in odwriteex.
if you get visible hatch for it and invisible for predefined angle the reson is missing (not found) acad.pat or acadiso.pat file as i wrote in one of previous posts.
hi sergey,
thank you for u'r response.
as u told, i tried with a custom defined pattern. but the result was same. its not hatching. it was the same piece of code in the odwriteex application.
the code follows..
odhatchpattern stars;
odhatchpatternline line;
oddbcircleptr pcircle;
oddbhatchptr phatch;
odgepoint3d point;
oddbobjectid hatchid;
oddbobjectidarray loopids;
odgepoint3d centerpt;
int w = 100;
oddbdatabase *pdb = theapp.m_pdb;
oddbblocktablerecordptr pblock = pdb->getmodelspaceid().safeopenobject(oddb::kforwrite) ;
line.m_dlineangle = 0.0;
line.m_patternoffset = odgevector2d(0, 0.866);
line.m_dashes.push_back(0.5);
line.m_dashes.push_back(-0.5);
stars.push_back(line);
line.m_dlineangle = 1.0472;
line.m_patternoffset = odgevector2d(0, 0.866);
stars.push_back(line);
line.m_dlineangle = 2.0944;
line.m_basepoint = odgepoint2d(0.25, 0.433);
line.m_patternoffset = odgevector2d(0, 0.866);
stars.push_back(line);
pdb->appservices()->patternmanager()->appendpattern(oddbhatch::kcustomdefined, "my_stars", stars);
try
{
phatch = oddbhatch::createobject();
point = odgepoint3d(50,50,0);
hatchid = pblock->appendoddbentity(phatch);
phatch->setassociative(true);
phatch->setpattern(oddbhatch::kcustomdefined, "my_stars");
phatch->setpatternscale(0.125);
phatch->setpatternangle(0.5);
phatch->sethatchstyle(oddbhatch::knormal);
pcircle = oddbcircle::createobject();
loopids.clear();
loopids.push_back(pblock->appendoddbentity(pcircle));
centerpt = point;
centerpt.x += w*4.0;
centerpt.y += w;
pcircle->setcenter(centerpt);
pcircle->setradius(w*3.0/2.0);
phatch->appendloop(oddbhatch::kdefault, loopids);
}
catch (oderror& e)
{
if (e.code() == einvalidinput)
{
messagebox("failed to locate acad.pat hatch pattern file -- hatches not added");
}
else
{
throw;
}
}
m_pdevice->invalidate();
redrawwindow();
what could be the cause of this problem.
thanks in advance.
expecting a reply...
thanks & regards,
rajesh parameswaran

rajuinnet
# 31st august 2004, 12:56 am

registered user join date: jul 2004
location: india
posts: 82


quote:
originally posted by rajuinnet
hi sergey,
thank you for u'r response.
as u told, i tried with a custom defined pattern. but the result was same. its not hatching. it was the same piece of code in the odwriteex application.
the code follows..
odhatchpattern stars;
odhatchpatternline line;
oddbcircleptr pcircle;
oddbhatchptr phatch;
odgepoint3d point;
oddbobjectid hatchid;
oddbobjectidarray loopids;
odgepoint3d centerpt;
int w = 100;
oddbdatabase *pdb = theapp.m_pdb;
oddbblocktablerecordptr pblock = pdb->getmodelspaceid().safeopenobject(oddb::kforwrite) ;
line.m_dlineangle = 0.0;
line.m_patternoffset = odgevector2d(0, 0.866);
line.m_dashes.push_back(0.5);
line.m_dashes.push_back(-0.5);
stars.push_back(line);
line.m_dlineangle = 1.0472;
line.m_patternoffset = odgevector2d(0, 0.866);
stars.push_back(line);
line.m_dlineangle = 2.0944;
line.m_basepoint = odgepoint2d(0.25, 0.433);
line.m_patternoffset = odgevector2d(0, 0.866);
stars.push_back(line);
pdb->appservices()->patternmanager()->appendpattern(oddbhatch::kcustomdefined, "my_stars", stars);
try
{
phatch = oddbhatch::createobject();
point = odgepoint3d(50,50,0);
hatchid = pblock->appendoddbentity(phatch);
phatch->setassociative(true);
phatch->setpattern(oddbhatch::kcustomdefined, "my_stars");
phatch->setpatternscale(0.125);
phatch->setpatternangle(0.5);
phatch->sethatchstyle(oddbhatch::knormal);
pcircle = oddbcircle::createobject();
loopids.clear();
loopids.push_back(pblock->appendoddbentity(pcircle));
centerpt = point;
centerpt.x += w*4.0;
centerpt.y += w;
pcircle->setcenter(centerpt);
pcircle->setradius(w*3.0/2.0);
phatch->appendloop(oddbhatch::kdefault, loopids);
}
catch (oderror& e)
{
if (e.code() == einvalidinput)
{
messagebox("failed to locate acad.pat hatch pattern file -- hatches not added");
}
else
{
throw;
}
}
m_pdevice->invalidate();
redrawwindow();
what could be the cause of this problem.
thanks in advance.
expecting a reply...
thanks & regards,
rajesh parameswaran
hi sergey,
i tried creating kuserdefined patterns, using the following functions
setpatternspace() , setpatternangle() ,and setpatterndouble();
and i got the hatches. it was a successful one.
but when i tried to create a kuserdefined pattern using the following
odhatchpattern , and odhatchpatternline
it didn't displayed any hatches, but it took lot of time for displaying the entity.
and the old problem still exist.. i'm using the oddb::measurementvalue as oddb::kenglish. and i've the file acad.pat.
my problem is i'm not able to use predefined hatches other than solid hatches..
please help..!!!!!!
thanks in advance
___________
thanks & regards,
rajesh parameswran.

rajuinnet
# 1st september 2004, 10:46 am

moderator join date: mar 2002
posts: 2,994
hatch patterns can be of 3 types:
user defined - simple hatching which is completely defined by oddbhatch methods setpatternspace(), setpatternangle() and setpatterndouble()
no pattern manager and .pat files are required in this case.
custom defined and predefined patterns are described in .pat files. predefined patterns reside in acad.pat file.
custom defined pattern must be described in file <patternname>.pat
dd's pattern manager loads the patterns from .pat file. but where is an option to avoid using .pat files - adding the patterns to pattern manager programmatically.
if you set pattern type to user defined and had not specified pattern space hatching routine probably tries to build the hatch using uninitialized values and after number of hatch lines aceeds some limit terminates the process. this takes much time.
odwriteex contains examples of creating hatch entities using different ways.
sergey slezkin

sslezkin
# 4th october 2004, 03:16 am

registered user join date: jul 2004
location: india
posts: 82

saving custom patterns
quote:
originally posted by sergey slezkin
hatch patterns can be of 3 types:
user defined - simple hatching which is completely defined by oddbhatch methods setpatternspace(), setpatternangle() and setpatterndouble()
no pattern manager and .pat files are required in this case.
custom defined and predefined patterns are described in .pat files. predefined patterns reside in acad.pat file.
custom defined pattern must be described in file <patternname>.pat
dd's pattern manager loads the patterns from .pat file. but where is an option to avoid using .pat files - adding the patterns to pattern manager programmatically.
if you set pattern type to user defined and had not specified pattern space hatching routine probably tries to build the hatch using uninitialized values and after number of hatch lines aceeds some limit terminates the process. this takes much time.
odwriteex contains examples of creating hatch entities using different ways.
hi sergey slezkin
i have created a custom defined pattern. when i save the file, and open it again, the hatch pattern cannot be seen.
does it required to save the hatch pattern in a .pat file..?
if so what is the procedure for that..?
tia
---------------------------
regards,
rajesh paramewaran

rajuinnet
# 4th october 2004, 03:59 am

moderator join date: mar 2002
posts: 2,994
odwriteex contains sample code creating hatch with custom patterm my_stars programmatically without using .pat file. it's visible in both autocad and dd based applications.
in autocad such hatch can't be edited without corresponding .pat file.
sergey slezkin

sslezkin
# 5th october 2004, 05:25 am

registered user join date: jul 2004
location: india
posts: 82

it works!!
quote:
originally posted by sergey slezkin
odwriteex contains sample code creating hatch with custom patterm my_stars programmatically without using .pat file. it's visible in both autocad and dd based applications.
in autocad such hatch can't be edited without corresponding .pat file.
hi sergey slezkin,
thanks for your information.
it works now..!!
---------------------------------
regards,
rajesh parameswaran.

rajuinnet
# 3rd november 2004, 04:49 am

registered user join date: mar 2004
posts: 15
user defined hatch !!
it still doesn't work for me !! i try to use a kuserdefined hatch but get a crash in the oddbhatchimpl::gethatchpattern() function !!
please help !!
soeren
// crash in oddbhatchimpl::gethatchpattern() at setpattern....
oddbhatchptr phatch = oddbhatch::createobject();
pblock->appendoddbentity(phatch);
phatch->setassociative(true);
//phatch->setpattern(oddbhatch::kpredefined, "angle");
phatch->setpattern(oddbhatch::kuserdefined, "_user");
phatch->setpatternspace(0.125);
phatch->setpatternangle(0.5); // near 30 degrees
phatch->setpatterndouble(true); // cross hatch
phatch->sethatchstyle(oddbhatch::knormal);

sa@ige-xao.dk
# 3rd november 2004, 07:04 am

moderator join date: mar 2002
posts: 2,994
the code seems to be extracted from odwriteex sample...
it works for me in odwriteex. which version do you use?
sergey slezkin

sslezkin
# 5th november 2004, 12:43 am

registered user join date: mar 2004
posts: 15
i am using version 1.12 !!
soeren

sa@ige-xao.dk
page 1 of 21

none
? | ?
thread tools



display modes
linear mode


search this thread

rate this thread
excellent
good
average
bad
terrible

posting rules
you may post new threads
you may post replies
you may post attachments
you may edit your posts
is on
are on
code is off
html code is off
forum jump
user control panel private messages subscriptions who's online search forums forums home general topics news questions and remarks business issues industry commentary general software issues documentation issues future directions dwg libraries dwgdirect.net dwgdirect, c++ version dwgdirectx, activex version adtdirect/c3ddirect opendwg toolkit/viewkit dgn libraries dgndirect, c++ version (2.x+) dgndirect libraries (legacy 0.99xx)
all times are gmt -7. the time now is 12:42 amfff">.
- - -
copyright ?2000 - 2009, jelsoft enterprises ltd.
copyright 1998-2008 open design alliance inc.
if acad.pat is available you can use hatch patterns from it.
hatch pattern manager will try to access acad.pat or acadiso.pat (english/metric) to load specified predefined pattern (it will call findfile() to locate it.
if you get empty hatches probably dd failed to access acad.pat or hatch scale is too large.
btw, odwriteex contains code illustrating different patterns usage.
sergey slezkin

quote:
originally posted by sergey slezkin
if acad.pat is available you can use hatch patterns from it.
hatch pattern manager will try to access acad.pat or acadiso.pat (english/metric) to load specified predefined pattern (it will call findfile() to locate it.
if you get empty hatches probably dd failed to access acad.pat or hatch scale is too large.
btw, odwriteex contains code illustrating different patterns usage.
hi sergey,
thank you for u'r reply. i've a better look on the sample project odwriteex. but it seems to be little bit confused. so here is the code, which i wrote for hatching the polylines.
kindly have a look and say whether is this the right way i'm doing.
if(pchildobj->iskindof(oddbpolyline::desc()))
{
oddbpolylineptr pchildobjpoly2d = pchildobj;
try
{
phatch = oddbhatch::createobject();
whitehatchid = pmainblock->appendoddbentity(phatch);
phatch->setassociative(true);
phatch->setcolorindex( k % 15 );
phatch->setpattern(oddbhatch::kpredefined, "angle");
phatch->sethatchstyle(oddbhatch::knormal);
vertexpts.resize(pchildobjpoly2d->numverts());
for (int i=0; i < pchildobjpoly2d->numverts(); i++)
{
pchildobjpoly2d->getpointat((unsigned int)i,
ptvertex);
vertexpts[i].set(ptvertex.x,ptvertex.y);
}
phatch->appendloop(oddbhatch::kexternal |
oddbhatch::kpolyline, vertexpts,vertexbulges);
}
catch(oderror &e)
{
str1.format("error: %s", e.description());
messagebox(str1);
}
}
thanks in advance,
regards,
rajesh parameswaran
1. your hatch will not be associative because you have not specified entities it should be associated with. use appendloop() accepting objectid array to create associative hatch.
2. hatch will be invisible if hatch pattern manager fails to find acad.pat. it calls oddbhostappservices::findfile() to get full path to acad.pat. you can override findfile() in your oddbhostappservices inheritor.
another way it to specify hatch pattern (even predefined) manually instead of using acad.pat. see odwriteex sample.
sergey slezkin

still hunting with hatching entities
quote:
originally posted by sergey slezkin
1. your hatch will not be associative because you have not specified entities it should be associated with. use appendloop() accepting objectid array to create associative hatch.
2. hatch will be invisible if hatch pattern manager fails to find acad.pat. it calls oddbhostappservices::findfile() to get full path to acad.pat. you can override findfile() in your oddbhostappservices inheritor.
another way it to specify hatch pattern (even predefined) manually instead of using acad.pat. see odwriteex sample.
hi sergey,
thanks for u'r response. as you said, i tried using appendloop() accepting objectid array to create associative hatch. i even tried the sample application odwriteex. i tried to draw a circle with angle hatch (associative).
the code is listed below...
oddbhatchptr phatch;
odgepoint3d point = odgepoint3d(120,120,0);
oddbdatabase *pdb = theapp.m_pdb;
oddbblocktablerecordptr pblock = pdb->getmodelspaceid().safeopenobject(oddb::kforwrite) ;
phatch = oddbhatch::createobject();
oddbobjectid hatchid = pblock->appendoddbentity(phatch);
phatch->setassociative(true);
phatch->setpattern(oddbhatch::kpredefined, "angle");
phatch->setpatternscale(0.5);
phatch->setpatternangle(0.5);
phatch->sethatchstyle(oddbhatch::knormal);
oddbobjectidarray loopids;
oddbcircleptr pcircle = oddbcircle::createobject();
loopids.push_back(pblock->appendoddbentity(pcircle));
odgepoint3d centerpt(point);
centerpt.x += 100*3.0/2.0;
centerpt.y -= 100;
pcircle->setcenter(centerpt);
pcircle->setradius(100*3.0/2.0);
phatch->appendloop(oddbhatch::kdefault, loopids);
m_pdevice->invalidate();
redrawwindow();
but even i tried this, its not hatching.. what may be the cause of the problem. is there anything wrong with the code.
is there any device specification for hatching. ? if so i'm able to hatch using solid hatches...so what could be the cause for the problem..
if u can show me the way of hatching with an example, it will be very helpful..
thanks in advance
thanks and regards,
rajesh parameswaran.
last edited by rajuinnet; 25th august 2004 at 11:38 pmfff">.
try to add a hatch pattern to pattern manager manually like my_stars in odwriteex.
if you get visible hatch for it and invisible for predefined angle the reson is missing (not found) acad.pat or acadiso.pat file as i wrote in one of previous posts.
sergey slezkin

still problem with custom defiened hatches
quote:
originally posted by sergey slezkin
try to add a hatch pattern to pattern manager manually like my_stars in odwriteex.
if you get visible hatch for it and invisible for predefined angle the reson is missing (not found) acad.pat or acadiso.pat file as i wrote in one of previous posts.
hi sergey,
thank you for u'r response.
as u told, i tried with a custom defined pattern. but the result was same. its not hatching. it was the same piece of code in the odwriteex application.
the code follows..
odhatchpattern stars;
odhatchpatternline line;
oddbcircleptr pcircle;
oddbhatchptr phatch;
odgepoint3d point;
oddbobjectid hatchid;
oddbobjectidarray loopids;
odgepoint3d centerpt;
int w = 100;
oddbdatabase *pdb = theapp.m_pdb;
oddbblocktablerecordptr pblock = pdb->getmodelspaceid().safeopenobject(oddb::kforwrite) ;
line.m_dlineangle = 0.0;
line.m_patternoffset = odgevector2d(0, 0.866);
line.m_dashes.push_back(0.5);
line.m_dashes.push_back(-0.5);
stars.push_back(line);
line.m_dlineangle = 1.0472;
line.m_patternoffset = odgevector2d(0, 0.866);
stars.push_back(line);
line.m_dlineangle = 2.0944;
line.m_basepoint = odgepoint2d(0.25, 0.433);
line.m_patternoffset = odgevector2d(0, 0.866);
stars.push_back(line);
pdb->appservices()->patternmanager()->appendpattern(oddbhatch::kcustomdefined, "my_stars", stars);
try
{
phatch = oddbhatch::createobject();
point = odgepoint3d(50,50,0);
hatchid = pblock->appendoddbentity(phatch);
phatch->setassociative(true);
phatch->setpattern(oddbhatch::kcustomdefined, "my_stars");
phatch->setpatternscale(0.125);
phatch->setpatternangle(0.5);
phatch->sethatchstyle(oddbhatch::knormal);
pcircle = oddbcircle::createobject();
loopids.clear();
loopids.push_back(pblock->appendoddbentity(pcircle));
centerpt = point;
centerpt.x += w*4.0;
centerpt.y += w;
pcircle->setcenter(centerpt);
pcircle->setradius(w*3.0/2.0);
phatch->appendloop(oddbhatch::kdefault, loopids);
}
catch (oderror& e)
{
if (e.code() == einvalidinput)
{
messagebox("failed to locate acad.pat hatch pattern file -- hatches not added");
}
else
{
throw;
}
}
m_pdevice->invalidate();
redrawwindow();
what could be the cause of this problem.
thanks in advance.
expecting a reply...
thanks & regards,
rajesh parameswaran


quote:
originally posted by rajuinnet
hi sergey,
thank you for u'r response.
as u told, i tried with a custom defined pattern. but the result was same. its not hatching. it was the same piece of code in the odwriteex application.
the code follows..
odhatchpattern stars;
odhatchpatternline line;
oddbcircleptr pcircle;
oddbhatchptr phatch;
odgepoint3d point;
oddbobjectid hatchid;
oddbobjectidarray loopids;
odgepoint3d centerpt;
int w = 100;
oddbdatabase *pdb = theapp.m_pdb;
oddbblocktablerecordptr pblock = pdb->getmodelspaceid().safeopenobject(oddb::kforwrite) ;
line.m_dlineangle = 0.0;
line.m_patternoffset = odgevector2d(0, 0.866);
line.m_dashes.push_back(0.5);
line.m_dashes.push_back(-0.5);
stars.push_back(line);
line.m_dlineangle = 1.0472;
line.m_patternoffset = odgevector2d(0, 0.866);
stars.push_back(line);
line.m_dlineangle = 2.0944;
line.m_basepoint = odgepoint2d(0.25, 0.433);
line.m_patternoffset = odgevector2d(0, 0.866);
stars.push_back(line);
pdb->appservices()->patternmanager()->appendpattern(oddbhatch::kcustomdefined, "my_stars", stars);
try
{
phatch = oddbhatch::createobject();
point = odgepoint3d(50,50,0);
hatchid = pblock->appendoddbentity(phatch);
phatch->setassociative(true);
phatch->setpattern(oddbhatch::kcustomdefined, "my_stars");
phatch->setpatternscale(0.125);
phatch->setpatternangle(0.5);
phatch->sethatchstyle(oddbhatch::knormal);
pcircle = oddbcircle::createobject();
loopids.clear();
loopids.push_back(pblock->appendoddbentity(pcircle));
centerpt = point;
centerpt.x += w*4.0;
centerpt.y += w;
pcircle->setcenter(centerpt);
pcircle->setradius(w*3.0/2.0);
phatch->appendloop(oddbhatch::kdefault, loopids);
}
catch (oderror& e)
{
if (e.code() == einvalidinput)
{
messagebox("failed to locate acad.pat hatch pattern file -- hatches not added");
}
else
{
throw;
}
}
m_pdevice->invalidate();
redrawwindow();
what could be the cause of this problem.
thanks in advance.
expecting a reply...
thanks & regards,
rajesh parameswaran
hi sergey,
i tried creating kuserdefined patterns, using the following functions
setpatternspace() , setpatternangle() ,and setpatterndouble();
and i got the hatches. it was a successful one.
but when i tried to create a kuserdefined pattern using the following
odhatchpattern , and odhatchpatternline
it didn't displayed any hatches, but it took lot of time for displaying the entity.
and the old problem still exist.. i'm using the oddb::measurementvalue as oddb::kenglish. and i've the file acad.pat.
my problem is i'm not able to use predefined hatches other than solid hatches..
please help..!!!!!!
thanks in advance
___________
thanks & regards,
rajesh parameswran.
hatch patterns can be of 3 types:
user defined - simple hatching which is completely defined by oddbhatch methods setpatternspace(), setpatternangle() and setpatterndouble()
no pattern manager and .pat files are required in this case.
custom defined and predefined patterns are described in .pat files. predefined patterns reside in acad.pat file.
custom defined pattern must be described in file <patternname>.pat
dd's pattern manager loads the patterns from .pat file. but where is an option to avoid using .pat files - adding the patterns to pattern manager programmatically.
if you set pattern type to user defined and had not specified pattern space hatching routine probably tries to build the hatch using uninitialized values and after number of hatch lines aceeds some limit terminates the process. this takes much time.
odwriteex contains examples of creating hatch entities using different ways.
sergey slezkin

saving custom patterns
quote:
originally posted by sergey slezkin
hatch patterns can be of 3 types:
user defined - simple hatching which is completely defined by oddbhatch methods setpatternspace(), setpatternangle() and setpatterndouble()
no pattern manager and .pat files are required in this case.
custom defined and predefined patterns are described in .pat files. predefined patterns reside in acad.pat file.
custom defined pattern must be described in file <patternname>.pat
dd's pattern manager loads the patterns from .pat file. but where is an option to avoid using .pat files - adding the patterns to pattern manager programmatically.
if you set pattern type to user defined and had not specified pattern space hatching routine probably tries to build the hatch using uninitialized values and after number of hatch lines aceeds some limit terminates the process. this takes much time.
odwriteex contains examples of creating hatch entities using different ways.
hi sergey slezkin
i have created a custom defined pattern. when i save the file, and open it again, the hatch pattern cannot be seen.
does it required to save the hatch pattern in a .pat file..?
if so what is the procedure for that..?
tia
---------------------------
regards,
rajesh paramewaran
odwriteex contains sample code creating hatch with custom patterm my_stars programmatically without using .pat file. it's visible in both autocad and dd based applications.
in autocad such hatch can't be edited without corresponding .pat file.
sergey slezkin

it works!!
quote:
originally posted by sergey slezkin
odwriteex contains sample code creating hatch with custom patterm my_stars programmatically without using .pat file. it's visible in both autocad and dd based applications.
in autocad such hatch can't be edited without corresponding .pat file.
hi sergey slezkin,
thanks for your information.
it works now..!!
---------------------------------
regards,
rajesh parameswaran.
user defined hatch !!
it still doesn't work for me !! i try to use a kuserdefined hatch but get a crash in the oddbhatchimpl::gethatchpattern() function !!
please help !!
soeren
// crash in oddbhatchimpl::gethatchpattern() at setpattern....
oddbhatchptr phatch = oddbhatch::createobject();
pblock->appendoddbentity(phatch);
phatch->setassociative(true);
//phatch->setpattern(oddbhatch::kpredefined, "angle");
phatch->setpattern(oddbhatch::kuserdefined, "_user");
phatch->setpatternspace(0.125);
phatch->setpatternangle(0.5); // near 30 degrees
phatch->setpatterndouble(true); // cross hatch
phatch->sethatchstyle(oddbhatch::knormal);
the code seems to be extracted from odwriteex sample...
it works for me in odwriteex. which version do you use?
sergey slezkin
i am using version 1.12 !!
soeren
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】exploding proxyentities into simple entities yang686526 DirectDWG 0 2009-05-05 10:20 AM
【转帖】exploding block references = invisible entities yang686526 DirectDWG 0 2009-05-05 10:17 AM
【转帖】entities not being vectorized yang686526 DirectDWG 0 2009-05-05 09:27 AM
【转帖】coping entities yang686526 DirectDWG 0 2009-05-04 06:18 PM
【转帖】block entities are not erased after the block deleting yang686526 DirectDWG 0 2009-05-04 04:46 PM


所有的时间均为北京时间。 现在的时间是 08:22 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多