.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use ExternalBoundedSurface?

1 REPLY 1
Reply
Message 1 of 2
Anonymous
459 Views, 1 Reply

How to use ExternalBoundedSurface?

In C++,AcGeExternalBoundedSurface is used like this:
// Get the subentity path for a face
AcDbFullSubentPath subPath(kNullSubent);
......
// Make a face entity to access the surface
AcBrFace faceEntity;
faceEntity.set(subPath);
......
Adesk::UInt32 numNurbs = 0;
AcGeExternalBoundedSurface** nurbs = NULL;
faceEntity.getSurfaceAsTrimmedNurbs(numNurbs, nurbs);

But I find that I cannot do like this way in .NET(The constructor of ExternalBoundedSurface class is hard to understood ).So can you tell me how to construct the ExternalBoundedSurface class?
Thanks in advance!
1 REPLY 1
Message 2 of 2
moogalm
in reply to: Anonymous

Hi,

 

I was jus browsing forums, found this post unanswered, 

Any one who comes to this forum via Google search should find it helpful

 

public static void TraverseTorusesInBrep()
{
    Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;
    Editor ed = doc.Editor;

    // Ask the user to select a solid
    PromptEntityOptions peo = new PromptEntityOptions("Select a 3D solid");
    peo.SetRejectMessage("\nA 3D solid must be selected.");
    peo.AddAllowedClass(typeof(Solid3d), true);
    PromptEntityResult per = ed.GetEntity(peo);

    if (per.Status != PromptStatus.OK)
        return;

    Transaction tr = db.TransactionManager.StartTransaction();
    using (tr)
    {
        BlockTable bt =
          (BlockTable)tr.GetObject(
            db.BlockTableId,
            OpenMode.ForRead,
            false
          );
        BlockTableRecord btr =
          (BlockTableRecord)tr.GetObject(
            bt[BlockTableRecord.ModelSpace],
            OpenMode.ForWrite,
            false
          );

        Solid3d sol =
          tr.GetObject(
            per.ObjectId,
            OpenMode.ForRead
          ) as Solid3d;

        // Check the solid for torus faces
        int torusCounter = 1;
        using (Brep brep = new Brep(sol))
        {
            foreach (Complex cmp in brep.Complexes)
            {
                foreach (Shell shl in cmp.Shells)
                {
                    foreach (BrFace fce in shl.Faces)
                    {
                        Autodesk.AutoCAD.Geometry.Surface surf = fce.Surface;
                        ExternalBoundedSurface ebSurf = surf as ExternalBoundedSurface;
                        if (ebSurf != null && ebSurf.IsTorus)
                        {
                            Torus torus = ebSurf.BaseSurface as Torus;
                            if (torus != null)
                            {
                                double[] uAngles = torus.GetAnglesInU();
                                ed.WriteMessage("\n Torus number " + torusCounter + ":");
                                ed.WriteMessage("\n\tAngle min:" + uAngles[0]);
                                ed.WriteMessage("\n\tAngle max:" + uAngles[1]);
                                torusCounter++;
                            }
                        }
                    }
                }
            }
        }
    }
}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost