查看单个帖子
旧 2009-05-07, 04:58 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】he Hatch Look Changes In Autocad

the hatch look changes in autocad
the hatch look changes in autocad
hi,
here i have a problem with hatch. now i am using dd 1.10 update 1.
here has a attachment file explode.dwg. opening this file in autocad, we can see there have two hatches in drawing. if we modify one of the hatch pattern scales to the original value( e.g. in the attachment file, this value is 0.5, we only write 0.5 again for this property fff"> ) in autocad, autocad updates this hatch and the look of it changes. in fact, the result is really what i want( it looks like the same as in my application). what does cause this difference?
regards
attached files

quote:
originally posted by enigma
what does cause this difference?
difference is because hatch pattern, that is inside hatch entity, is different with autocad honey pattern. how do you create this hatch (code)?
sincerely yours,
george udov
hi,
the following is my code to create a hatch:
odhatchpattern hatchptn;
oddbhatchptr phatch = oddbhatch::createobject( );
phatch->setlayer( layerid );
phatch->setcolorindex( entcolor );
phatch->setelevation( elevation );
phatch->setassociative( false );
phatch->setpixelsize( 0.0 );
//append loop
phatch->appendloop(oddbhatch::kpolyline,vertexpts, vertexbulges);
phatch->sethatchstyle( oddbhatch::knormal );
phatch->setpatternangle( patternangleradians );
phatch->setpatterndouble( false );
// pattern line angle
for( int i = 0; i< linecount; i++ )
{
odhatchpatternline hatchline; hatchline.m_dlineangle = lineangle;
// base point
double patternthrough[2];
.... // fill in patternthrough here
hatchline.m_basepoint.set( patternthrough[0],patternthrough[1] );
hatchline.m_patternoffset.set( patternoffset[0],patternoffset[1] );
// dash lengths
for (short j=0, sign=1;j<dashlengthitems; j++, sign *= -1)
{
double dashitem = ...; //fill in dashitem;
hatchline.m_dashes.append(dashitem);
}
hatchptn.append( hatchline );
}
if( oddb::kenglish == pdb->getmeasurement() )
pdb->appservices()->patternmanager()->appendpattern(oddbhatch::kcustomdefined, odstring(patternname ),hatchptn);
else if( oddb::kmetric == pdb->getmeasurement() )
pdb->appservices()->patternmanager()->appendpattern (oddbhatch::kcustomdefined, odstring(patternname ),hatchptn,oddb::kmetric);
else
assert( 0 );
phatch->setpattern( oddbhatch::kcustomdefined, patternname );
phatch->setpatternscale( scale );
pblock->appendoddbentity( phatch );
here i create a custom defined hatch.
autocad has predefined hatch with the same name "honey". when you change something in the hatch entity properties autocad recalculates the hatch. to perform the operation it needs pattern definition (in acad.pat for predefined hatches and <pat_name>.pat for custom hatches.
honey.pat is absent but pattern with the same name presents in acad.pat. autocad uses its prederfined honey to perform the operation. at the same moment hatch type changes from "custom" to "predefined". autocad's predefined honey definition is different from yours custom one.
it's not safe to use custom pattern with the same name as existing predefined one.
btw, if you want your hatch with custom pattern editable in autocad you need to supply corresponding .pat file.
sergey slezkin
hi,
thanks for your reply!
here has two attachment files: drawing1.dwg and drawing6.dwg. in these files, the hatch pattern name has been changed to honeyic, so it will not be replaced by the predefined one in autocad. opening the two files in autocad, we can see that the two hatches using honeyic pattern look different. they only have the different pattern scale. what does cause them look different?
regards
attached files (19.0 kb, 5 views)
(17.2 kb, 4 views)


they look different because they have different patterns. pattern line offsets are equal, while other pattern fields are different with scale 0.2.
sincerely yours,
george udov
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)