高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】a hatch problem
a hatch problem
a hatch problem
here i have a hatch probelm, it cannot export the hatch line correctly. the following is my code to export a hatch. in the following code i used the real value in debugging to replace the paremeters:
oddbhatchptr phatch = oddbhatch::createobject( );
odhatchpattern hatchptn;
pdb->appservices()->patternmanager()->appendpattern (oddbhatch::kuserdefined, patternname,hatchptn);
phatch->setpattern( oddbhatch::kuserdefined, patternname );
phatch->setassociative( false );
phatch->setelevation( 0 );
phatch->setpixelsize( 0.0 );
phatch->setpatterndouble( false );
.......
phatch->appendloop(oddbhatch::kpolyline,vertexpts, vertexbulges);
phatch->sethatchstyle( oddbhatch::knormal );
phatch->setpatternangle( 0.0 ); // in the attachment case, this angle is
// 0, so i use 0 directly here, it is to say
//that the pattern in this hatch isn't rotated, it is right?
phatch->setpatternspace( dspace );
phatch->setpatterndouble( false );
odhatchpatternline hatchline; //create the hatch line
hatchline.m_dlineangle = pi/4.0; //in the attachment case, this angle
//is pi/4, so here i use this value directly
hatchline.m_basepoint.set(0.0, 0.6);
hatchline.m_patternoffset.set(0.0, 3.0);
hatchptn.append( hatchline );
pblock->appendoddbentity( phatch );
in this case, i need the angle between the hatch line and the horizon is pi/4 . but open the attachment file in autocad, we can see the hatch line is horizontal. in these code i must do somethings error or miss doing something, but i can't find out them.
thanks for your help!
attached files
1. user defined pattern is completely described by angle, spacing and cross flag. it can represent only simple hatching.
pattern definition is used only for predefined and custom hatches.
2. you need to add pattern definition lines to pattern before appending pattern to pattern manager.
sergey slezkin
a hatch problem
quote:
originally posted by sergey slezkin
1. user defined pattern is completely described by angle, spacing and cross flag. it can represent only simple hatching.
pattern definition is used only for predefined and custom hatches.
2. you need to add pattern definition lines to pattern before appending pattern to pattern manager.
hi, sergey,
from your reply, i have modified code to add pattern definition lines to pattern before appending pattern to pattern manager. here i have several questions also need your help.
"pattern definition is used only for predefined and custom hatches.", do you mean that a user defined hatch doesn't need a hatch pattern?
in a hatch, there has two angle parameters: pattern angle(set by setpatternangle) fff"> and hatch line angle(stored in odhatchpatternline.m_dlineangle)fff">. i think that in the hatch entity(not in a hatch pattern), the angle between hatch line and the horizon should be equal to (pattern angle)+(hatch line angle)fff">, is it right?
i found that in my application: firstlyfff"> exporting a hatch with a named pattern e.g. "normal", thenfff"> modifying the hatch line angle in the pattern, and then fff"> exporting the hatch again, the data gotten are the latest data and assigned to the hatch pattern, but in autocad the angle between hatch line and the horizon is not changed. i used retrievepattern() to get the pattern to see the data, it showed that the pattern still contained the old data. but after fff"> modifying the pattern name, the new pattern angle fff"> will be used. i think the reason maybe is that the secod pattern can't overwrite the same named pattern e.g. "normal" which has existed in pattern manager, dd always uses the first pattern data to export the hatch. so here i have another several questions : what i think is right? if it's right, what can i do to avoid this case? is our responsibility to update the data contained in pattern if we modified the pattern data?
best regards
user defined hatch does not need pattern definition.
in hatch where is only one angle - overall pattern rotation. pattern definition may contain multiple lines with individual angle each. the resulting angle is equal to hatch line angle in pattern plus pattern rotation.
pattern names must be unique. if you replace pattern definition after a hatch entity with this pattern is already created in general the result is unpredictable. to be sure that new definition has effect you need to call phatch->setpattern() once more.
sergey slezkin
quote:
originally posted by sergey slezkin
user defined hatch does not need pattern definition.
in hatch where is only one angle - overall pattern rotation. pattern definition may contain multiple lines with individual angle each. the resulting angle is equal to hatch line angle in pattern plus pattern rotation.
pattern names must be unique. if you replace pattern definition after a hatch entity with this pattern is already created in general the result is unpredictable. to be sure that new definition has effect you need to call phatch->setpattern() once more.
how can we delete a hatch pattern having been existed in pattern manager. the is no function in pattern manager to do this.
it's impossible to delete pattern.
sergey slezkin
|