3d solid from 3d polyline

3d solid from 3d polyline

Anonymous
Not applicable
2,191 Views
7 Replies
Message 1 of 8

3d solid from 3d polyline

Anonymous
Not applicable

I have 3d polyline and want to create 3d solid, based on it.

i have to:

1.extrude polyline on some height

2. create bottom (my 3d polyline) and top (my polyline's copy moved at the same height) surfaces

3. use createSculptedSolid to create 3d solid.

here is the code of my function

AcDbObjectId add3dSolid(AcDbObjectId poly3dID, // bottom polyline 
         double height, // height for extrude and top polyline
         Adesk::UInt16 Color = 0, 
         const ACHAR* Layer = NULL, 
         ACHAR * ModelPaperSpace = ACDB_MODEL_SPACE); 

AcDbObjectId add3dSolid(AcDbObjectId poly3dID, double height, Adesk::UInt16 Color, const ACHAR* Layer, ACHAR * ModelPaperSpace) 
{ 
   Acad::ErrorStatus es; 
   AcDbObjectId eIdTop; 
   AcDbObjectId eId = AcDbObjectId::kNull; 
   AcDbEntity * pEnt; 
   if (Acad::eOk != acdbOpenObject(pEnt,poly3dID,AcDb::kForRead)) return eId; 
   AcDbEntity *pEntTop = (AcDbEntity*)pEnt->clone(); 
   AcGeMatrix3d mat; 
   mat.setToTranslation(AcGeVector3d(0.0,0.0,height)); 
   pEntTop->transformBy(mat); 
   es = postToDbase(pEntTop, eIdTop, ModelPaperSpace); // add top polyline to db 

   pEnt->close(); 
   AcDb3dProfile *pSweepPerimeter = new AcDb3dProfile(pEnt); 
   AcDbSweepOptions swepOptions; 
   AcDbObjectId newId; 
   AcDbSurface * pPerimeter; 
   AcDbSurface * pTop; 
   AcDbSurface * pBottom; 
   es = AcDbSurface::createExtrudedSurface(pSweepPerimeter,AcGeVector3d(0.0,0.0,height),swepOptions,(AcDbExtrudedSurface*&)pPerimeter); 

   AcDb3dProfile *pSweepBottom = new AcDb3dProfile(pEnt); 
   AcDbPathRef pathRef; 
   pSweepBottom->getPathRef(pathRef); 
   AcDbObjectIdArray idArr; 
   es = AcDbSurface::createPatchSurface(pathRef, idArr,0,0.0,pBottom); 

   AcDb3dProfile *pSweepTop = new AcDb3dProfile(pEntTop); 
   AcDbPathRef pathRefTop; 
   pSweepTop->getPathRef(pathRefTop); 
   idArr.removeAll(); 
   es = AcDbSurface::createPatchSurface(pathRefTop, idArr,0,0.0,pTop); 
    
   AcArray<AcDbEntity*> surfacesArray; 
   surfacesArray.append(pPerimeter); 
   surfacesArray.append(pTop); 
   surfacesArray.append(pBottom); 

   AcDb3dSolid *pSolid = new AcDb3dSolid(); 
   pSolid->setDatabaseDefaults(); 
   AcGeIntArray limits; 
   AcDbEntity *pSurfaceEnt; 

   es = pSolid->createSculptedSolid(surfacesArray, limits); // sometimes fails ))) 
   if(es == Acad::eOk) 
   { 
      if (Color != 0) pSolid->setColorIndex(Color); 
      if (isLayerExists(Layer)) pSolid->setLayer(Layer); 
      pSolid->setLinetype(_T("Continuous")); 
      es = postToDbase(pSolid, eId, ModelPaperSpace); 
      if (es == Acad::eOk) 
      { 
         es = pSolid->draw(); 
         es = pSolid->close(); 
      } 
   } 
   else 
   { 
      delete pSolid; 
   } 

   delete pPerimeter; 
   delete pTop; 
   delete pBottom; 
   delete pSweepBottom; 
   delete pSweepTop; 
   delete pSweepPerimeter; 
   deleteEntities(eIdTop); // delete top polyline from db 
   return eId; 
}

 the most wondering thing is that autocad sometimes can't create 3d solid because of "holes" between surfaces (attached dwg. black contour is ok, but red is wrong even for native autocad commands).

is that bug or expected behavior? 🙂

and how can i get 3d solid if this way is wrong?

 

0 Likes
2,192 Views
7 Replies
Replies (7)
Message 2 of 8

Alexander.Rivilis
Mentor
Mentor

Two comments:

1. This code is potentially dangerous:

pEnt->close(); 
AcDb3dProfile *pSweepPerimeter = new AcDb3dProfile(pEnt); 

 2. Red polyline is closed and also position of first vertex is equal position of last vertex. Maybe a bug in it - I have not tested the code.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 3 of 8

Anonymous
Not applicable

1. agree. also there is no acdbAcisSetDeleteBulletins(Adesk::kTrue); at the beginning of the function and acdbAcisDeleteModelerBulletins(); at the end. I've already fixed it.

2. black polyline i created manualy. my base code creates such contours as red polyline. and 99\100 works fine. this red contour is 100-th 🙂

 

arx with a help of its mechanisms creates 2 neighboring surfaces from 1 contour with "holes" at borders (extruded/bottom and extruded/top)

and as i understand it's a bug that'll never be fixed, hope i'm wrong :).

 

 

0 Likes
Message 4 of 8

Alexander.Rivilis
Mentor
Mentor

It is look like a bug. 10-th and 11-th vertexes (in left-buttom corner) of polyline make problem. If you increase distance between those vertexes - 3Dsolid will be created.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 5 of 8

Anonymous
Not applicable

unfortunately, i cant modify polyline. base module gives it to me "as is". these 10-th and 11-th points are just a special case. if i knew the limit on the length of adjacent points, I'd be able to correct the situation (only if points are on the same ray). but now it's just a guesswork. 

using autocad commands i created 3 surfaces (top, bottom, extruded). then i executed "_interfere" command to find problems. 

here what i got.

bottom contour above (z axis is downward)

bottom contour has 3 holes, top - 2.

_interfere.jpg

 

0 Likes
Message 6 of 8

Anonymous
Not applicable

it's too bad that surface doesn't use base contour as a border.
if this was so, the problems would not have arisen.

so, is there any other way to create 3d solid, using 3d polyline as its bottom border?

0 Likes
Message 7 of 8

diagodose2009
Collaborator
Collaborator

i fix the routineSmiley Sad

when i testing your source, for me, working fine.........

only minor bug with material,but do no crash...........

 

 

please contact me if you need the help............

You see the avi files with Bsplayer.exe for windows

You rename the ".zip" to *.rar at file "conpwdag_tutorial.zip"

E..g. conpwdag_tutorial.zip - > conpwdag_tutorial.rar

Thanks...........

 

 Thanks
Discussion_Admin

0 Likes
Message 8 of 8

Anonymous
Not applicable

diagodose2009, nice private message. it made me laugh

 

Spoiler
Hello..
You are happy,, i fix you routine.........
I test your routine (source)add
For me your routine work fine...............
I rewrite the source (3hours)
http://dl.transfer.ro/nick1986-transfer_ro-08mar-68c793.rar

I can work for your for low price..
You select bellow list
a) you pay 5$/hour ,(minim price) and i work for you..ARX programmer......................
b)you pay me 10\$/hour (normal price)
c)you pay me (>10$)/ hour you are BOSS!!!
Thanks..........

1. im happy. you make me laugh.

2. video shows you fix nothing ))) red polyline doesn't become 3d solid (it's impossible to do it. if you can make video of red polyline convertation, it would be your polyline (not my vertexes)).

3. for you it works fine because you want money doing nothing ))). you spent 3 hours to make my function works ))) for normal contour. (it takes 3-5 minutes to create new project in VS from 0 or less to add function to existing project, but not 3 hours) oh, i forgot, +2 minutes to create and compress video and +1 minute to calculate your salary and write pm)))

4. stop spamming to my private messages. 

 

P.S.: it's better to say nothing if you cant help

 

0 Likes