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

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】exported hatch patterns dot appear in acad (http://www.dimcax.com/hust/showthread.php?t=16235)

yang686526 2009-05-05 10:29 AM

【转帖】exported hatch patterns dot appear in acad
 
exported hatch patterns do't appear in acad
exported hatch patterns do't appear in acad
we export hatch patterns (beside other things) using dwgdirect. as we learned, the pattern gets stored in a <patname>.pat file instead of the hatch entity (unlike opendwg).
the only problem is that when autocad reads these files the hatch patterns are not shown.
in order to make them appear we have to explode the blocks containing the hatches, then select the hatches (one by one...) and manually adjust something to make the pattern appear (e.g. adjusting the pattern angle is efficient but nothing happens when the color or layer getts changed...)
i copy part of the code here:
hatch->setpattern (oddbhatch::kcustomdefined, (const char*) cname); // cname contains the name of the pattern
hatch->setpatternangle (pattern.angle);
if (!hatchpatterns.containskey (cname)) {
//creating pat file
<write the content of the pat file>
}
what did we miss or did wrong???
hatch patterns can be of 3 types: predefined (stored in acad.pat or acadiso.pat), customdefined (stored in separate .pat file with the same name as pattern and userdefined (only angle, spacing and "cross" flags are specified - no need in pattern definition).
in order to create a hatch which is displayed by autocad pattern should present in hatch entity too (scaled and rotated accordingly to hatch entity properties).
the difference between odt and dwgdirect is that pattern stored in hatch entity is calculated (scaled and rotated) by dwgdirect and in odt it is calculated manually. but to perform this dwgdirect needs access to pattern definition in the form as it is stored in .pat file.
you can use not only customdefined but predefined patterns too (no need in writing .pat file in this case).
to get definition of hatch patterns dwgdirect uses pattern manager interface (implementation can be applicaion specific).
see odwriteex sample illustrating hatch creating and using sample implementation of hatch pattern manager.
sergey slezkin
hi sergey,
thank you for the suggestions. but it needed some experimenting too...
the trick was to
1. write the pat file first
2. modify my findfile support because originally it used the base class oddbhostappservices::findfile for the pat files. and our code writes the pat file next to the dwg (and at that moment dwgdirect doesn't know where it will be - maybe it wouldn't use it even if it knew)
tibor
if you need .pat file together with .dwg it's ok. but if you need only .dwg as a result of your program you need not write .pat file.
odwriteex contains code illustrating how to make patern "known" to dwgdirect without writing .pat file.
sergey slezkin


所有的时间均为北京时间。 现在的时间是 05:13 AM.