高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】how to create region with hole
how to create region with hole ??
how to create region with hole ??
hello, i am a newbee in dwg direct use .
i'm testing dwgdirect in order to represent a wall with windows and doors. my aim is to create a face with holes as doors and windows.
i had tried to do that with a polygone as the wall and hole but i couldn't do a correct shadowing, i had also thought about a 3d face but it seemed very complicated to have a complex face with a few holes. i can have one or more holes in the wall and they can be placed anywere on this.
the simplest solution i see is to use region, 3dsolid and boolean operation. but i don't know how to create a simple 3dsolid like a cube or a simple region like a rectangle and how to substract one from the other with boolean operation. it seems that a boolean operation does not currently exist in dwgdirect (it's a comment in odregion.h) but a method may exist to build a complex region with holes.
if you have any idea or sample of how to do this could you tell me, please, because i need to know if it's possible as soon as possible.
thank you for reading me
yours sincerely
dd does not contain functionality for boolean operations with acis objects. the only method of creating such object is to specify its sat data.
if you need to create 3d wall you can use oddbpolyfacemesh. you need to specify vertices and faces.
if you want to create a polygon with holes you can use oddbhatch (with solid fill)
sergey slezkin
thanks sergey,
do you know whether the boolean operation functionality will be introduced in dd? if yes, when ?
i tried to find an api for sat data but i didn't find a simple and free one. i
found asdkamodeler.lib with autocad but i don't think i can use it for free
and i don't know if it's adapted for sat data.
perhaps you have a sat data api to advise for my search.
if i want to use oddbpolyfacemesh i must calculate faces and with a few holes it's very complex.
i also tried to use oddbhatch with solid fill but i can't produce a valid hatch with a vertical wall.
i have a good hatch if all my vertex are in the xy plan but when i try to do a vertical wall that is perpendicular to this xy
plan, i just get a hatch point in my dwg. i tried to use setnormal of oddbhath but i don't get a good hatch either.
have you got an idea of what is missing to build a good hatch ?
thank you for reading me
yours sincerely
//--desc--////////////////////////////////////////////////////
oddbblocktablerecordptr pblock = mpdb->getmodelspaceid().safeopenobject(oddb::kforwrite) ;
oddbhatchptr phatch = oddbhatch::createobject();
oddbobjectid hatchid = pblock->appendoddbentity(phatch);
double dist2kz = 5*(sqrt(2));
odgevector3d norm2wal(odgevector3d::kxaxis+odgevector3d::kyaxis );
norm2wal*=10;
// set the hatch properties.
phatch->setassociative(true);
phatch->setpattern(oddbhatch::kpredefined, "solid");
phatch->sethatchstyle(oddbhatch::knormal);
// with or without this line i have a point for my hatch
phatch->setnormal(norm2wal);
phatch->setelevation(dist2kz);
oddblineptr pline;
// array for boundary objects' ids
oddbobjectidarray loopids;
pline = oddbline::createobject();
loopids.push_back(pblock->appendoddbentity(pline));
pline->setstartpoint(odgepoint3d(10,0,2));
pline->setendpoint(odgepoint3d(10,0,12));
pline = oddbline::createobject();
loopids.push_back(pblock->appendoddbentity(pline));
pline->setstartpoint(odgepoint3d(10,0,12));
pline->setendpoint(odgepoint3d(0,10,12));
pline = oddbline::createobject();
loopids.push_back(pblock->appendoddbentity(pline));
pline->setstartpoint(odgepoint3d(0,10,12));
pline->setendpoint(odgepoint3d(0,10,2));
pline = oddbline::createobject();
loopids.push_back(pblock->appendoddbentity(pline));
pline->setstartpoint(odgepoint3d(0,10,2));
pline->setendpoint(odgepoint3d(10,0,2));
phatch->appendloop(oddbhatch::kdefault, loopids);
loopids.clear();
//--fdesc--///////////////////////////////////////////////////
currently we do not plan to implement boolean operations with 3dsolids.
the method you use to create hatch really does not work on other than xy plane. this is our bug. thanks for pointing it out.
you can use other appendloop() methods which accepts 2d geometry as input - edge array or array of 2d vertices. 2d geometry is specified in hatch's ocs. this should work. and it makes no sence to add entities to the database if they are used only for hatch creation.
but note that hatch is a "flat" entity - your wall will have zero thickness.
sergey slezkin
thanks again sergey,
i didn't use edge array for my hatch because i want 3d point.
i had solved my problem with a "transformby" to put my wall on xy plan then i applied a "transformby" with the inverted matrix on the hatch but it's not a beautiful solution.
yours sincerely
arnaud
creating unnecessary database entities is far from ideal too.
the way i suggested is:
1. specify hatch's plane by setnormal() and setelevation()
2. convert your 3d geometry to 2d (hatch's ocs) applying transform odgematrix3d::worldtoplane(normal)
3. specify hatch loops using 2d geometry.
the hatch is in its right plane already. no need in calling oddbhatch::transformby(invertedmatrix)
sergey slezkin
no worry sergey,
i'd use 3d entities in my sample but i'm using odgepoint2darray with no unnecessary database entities in my program. i just did that to create a hatch directly on an nonxy plan.
yours sincerely
arnaud
|