TheSwamp

Code Red => .NET => Topic started by: jh_dempsey on November 08, 2017, 03:32:25 AM

Title: help with 3d solid .separatebody function
Post by: jh_dempsey 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.
Title: Re: help with 3d solid .separatebody function
Post by: MickD 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
Title: Re: help with 3d solid .separatebody function
Post by: jh_dempsey 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
Title: Re: help with 3d solid .separatebody function
Post by: MickD on November 08, 2017, 04:10:51 AM
Cool!