Author Topic: help with 3d solid .separatebody function  (Read 73 times)

0 Members and 1 Guest are viewing this topic.

jh_dempsey

  • Mosquito
  • Posts: 2
help with 3d solid .separatebody function
« on: November 08, 2017, 03:32:25 am »
Hi All

I have a single solid which is made up of multiple discrete 3d solid objects (see attached image). I want to separate them out into individual solids, so the solid3D.separatebody() function seems to be the way to do this:

http://help.autodesk.com/view/OARX/2018/ENU/?guid=OREFNET-Autodesk_AutoCAD_DatabaseServices_Solid3d_SeparateBody

The above link tells me that:

Quote
This method separates the solid into a list of solids representing the additional disjoint volumes. This solid is reduced to a solid with one volume. The calling application is responsible for the resulting entities (either appending them to a database or deleting them when they are no longer needed). When the calling application closes this Solid3d, the resulting solid will be committed to the database. So, if the other solids are not appended to the database, you will lose some data.

What I cant work out is how to find out what the other objects are that this has created. I would have thought it would return a list of ObjectIDs or an ObjectIDCollection, but it returns nothing. How do I know what objects it has produced so I can add them to the block table? Running the separatesolids() function leaves me with just one of my solids and has deleted the rest.

MickD

  • Gator
  • Posts: 2947
  • I don't need a job, I need Money!!
Re: help with 3d solid .separatebody function
« Reply #1 on: November 08, 2017, 03:53:05 am »
do you have some code to look at, will help to see how you have it set up.

Looking at the method signature (which has a formatting error and the description should say it returns an array, not a list!) you should have something like:

Solid3d[] solids = solid3D.separatebody();

then use 'solids' array to do your stuff.

hth
"A language that doesn’t have everything is actually easier to program in than some that do."

        — Dennis M. Ritchie

jh_dempsey

  • Mosquito
  • Posts: 2
Re: help with 3d solid .separatebody function
« Reply #2 on: November 08, 2017, 04:09:24 am »
Perfect MickD. That's all I needed to know  :-)
Not got it working with the following code

Code: [Select]
            ' We now have all the solids created. We now need to split those solids into separate objects
            For Each combinedSolidId As ObjectId In combined3DsolidCollection
                Dim combinedSolid As Solid3d = trans.GetObject(combinedSolidId, OpenMode.ForWrite)
                Dim individualSolids() As Solid3d
                individualSolids = combinedSolid.SeparateBody() 'This resturns an array of solid3D objects
                For Each solid As Solid3d In individualSolids
                    acBlkTblRec.AppendEntity(solid)
                    trans.AddNewlyCreatedDBObject(solid, True)
                Next
            Next

MickD

  • Gator
  • Posts: 2947
  • I don't need a job, I need Money!!
Re: help with 3d solid .separatebody function
« Reply #3 on: November 08, 2017, 04:10:51 am »
Cool!
"A language that doesn’t have everything is actually easier to program in than some that do."

        — Dennis M. Ritchie