.NET

Reply
Contributor
17 Posts
0 Kudos
Registered: ‎02-29-2012
Post 1 of 8
Accepted Solution

Get Point Collection from 3dsolid

501 Views, 7 Replies
02-29-2012 03:49 PM

I know this must be an easy answer, but for the life I me I can't find the method that returns a point collection for a given 3dsoild.  I have to think that a property exists that contains all the points for a solid (the ones shown when you select a 3dsolid).  I appreciate the help.  Thanks!

Hi,

 

If you only need the solid vertices, you don't need to run through the whole brep tree.

 

Here's a little sample.

 

 public Point3dCollection GetSolidVertices(ObjectId id)
{
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Solid3d sol = tr.GetObject(id, OpenMode.ForRead) as Solid3d;
if (sol == null) return null;
try
{
Point3dCollection pts = new Point3dCollection();
using (Brep brp = new Brep(sol))
{
foreach (var vtx in brp.Vertices)
{
pts.Add(vtx.Point);
}
return pts;
}
}
catch { return null; }
}
}

 

Moderator
1,465 Posts
277 Kudos
Registered: ‎04-09-2008
Post 2 of 8

Re: Get Point Collection from 3dsolid

02-29-2012 10:36 PM in reply to: wein3967

Solution: http://through-the-interface.typepad.com/through_the_interface/2008/09/traversing-a-3d.html


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Contributor
17 Posts
0 Kudos
Registered: ‎02-29-2012
Post 3 of 8

Re: Get Point Collection from 3dsolid

03-01-2012 05:39 AM in reply to: wein3967

Thank you for the link.  I guess it wasn't quite as easy as I would have thought.  I figured there would just be a property for 3dsolids that contained all the points.  Never the less, I can probably get that code to work.  Thanks again.

*Expert Elite*
2,142 Posts
255 Kudos
Registered: ‎04-29-2006
Post 4 of 8

Re: Get Point Collection from 3dsolid

03-03-2012 02:28 AM in reply to: wein3967

Hi,

 

If you only need the solid vertices, you don't need to run through the whole brep tree.

 

Here's a little sample.

 

        public Point3dCollection GetSolidVertices(ObjectId id)
        {
            Database db = HostApplicationServices.WorkingDatabase;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                Solid3d sol = tr.GetObject(id, OpenMode.ForRead) as Solid3d;
                if (sol == null) return null;
                try
                {
                    Point3dCollection pts = new Point3dCollection();
                    using (Brep brp = new Brep(sol))
                    {
                        foreach (var vtx in brp.Vertices)
                        {
                            pts.Add(vtx.Point);
                        }
                        return pts;
                    }
                }
                catch { return null; }
            }
        }

 

Gilles Chanteau
Contributor
17 Posts
0 Kudos
Registered: ‎02-29-2012
Post 5 of 8

Re: Get Point Collection from 3dsolid

03-03-2012 06:13 AM in reply to: _gile

Thanks _guile, that was more along the lines of what I was looking for.  Excellent.

Mentor
713 Posts
4 Kudos
Registered: ‎04-21-2006
Post 6 of 8

Re: Get Point Collection from 3dsolid

11-08-2013 03:03 AM in reply to: wein3967

 

Sorry for my ignorance but when I convert this to VB.Net I get an unknown type for 'var'...?

 

*Expert Elite*
2,142 Posts
255 Kudos
Registered: ‎04-29-2006
Post 7 of 8

Re: Get Point Collection from 3dsolid

11-08-2013 03:38 AM in reply to: Hugh_Compton

Hi,

 

In C#, var keyword stands for 'implicit type', the (strongly typed) variable type is determined by the compiler at edition time.

In this case, the infered type is: Autodesk.AutoCAD.BoundaryRepresentation.Vertex

Gilles Chanteau
Mentor
713 Posts
4 Kudos
Registered: ‎04-21-2006
Post 8 of 8

Re: Get Point Collection from 3dsolid

11-08-2013 03:52 AM in reply to: _gile

Thanks Giles!

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!