section trough 3D solid using C#

Hi,

I created 3D solid and want to create a section trough it. In Bricscad command line I do '_section'. It prompts me to select the entity. Then it prompts me for 1st, 2nd and then 3rd point of my section plane and it creates new entity of Region type.

I would like to achieve the same using C#. I added all 'using' statements as in provided example. It is pointing to Bricscad and Teigha libraries. Then in my void I am getting points from the user:

[code]_AcEd.PromptPointOptions pntOpt1 = new PromptPointOptions("Get 1st point at roof base (it will be an origin of newly created local coordinate system). ");_AcEd.PromptPointResult pntRes1 = editor.GetPoint(pntOpt1);_AcEd.PromptPointOptions pntOpt2 = new PromptPointOptions("Get 2nd point at roof base (it will point +x direction of newly created local coordinate system). ");_AcEd.PromptPointResult pntRes2 = editor.GetPoint(pntOpt2);[/code]
It works as expected. Then I did the following:

[code] Point3d startPoint = new Point3d(pntRes1.Value.X, pntRes1.Value.Y, pntRes1.Value.Z);Point3d endPoint = new Point3d(pntRes2.Value.X, pntRes2.Value.Y, pntRes2.Value.Z);Point3d lastPoint = new Point3d(pntRes2.Value.X, pntRes2.Value.Y, pntRes2.Value.Z+1000);Point3d[] myPlane = new Point3d[3];myPlane[0] = startPoint;myPlane[1] = endPoint;myPlane[2] = lastPoint;Point3dCollection pt3d = new Point3dCollection(myPlane);Vector3d vct3d = new Vector3d(0, 0, 1000);Section mySection = new Section(pt3d, vct3d);mySection.Name = "TRUSS0010"; ccclsCadUtils.AddToModelSpace(mySection);[/code]

It created Section entity rather then region as I expected when using Bricscad command line. Is there any way I can
create region similarly as when using Bricscad command line? I would like to have some documentation or examples.
If it was possible to purchase some textbook or manuals that would be great - just need to speed up the process of
learning.

Many thanks

best regards
jiri

Comments

  • Jiri,

    try to use this code and the result section entity will be a region...
                         .................
                                    Solid3d solEnt = tr.GetObject(objId, OpenMode.ForRead) as Solid3d;
                                    Region reg = solEnt.GetSection(sPlane);
                                    btr.AppendEntity(reg);
                                    tr.AddNewlyCreatedDBObject(reg, true);

                         ..................

    hope this helps
  • just a small code addition ...!!!!

    get the plane from user...
     
                            Point3d p1 = new Point3d();
                            Point3d p2 = new Point3d();
                            Point3d p3 = new Point3d();
                            p1 = ed.GetPoint("Pick 1st Plane point :").Value;
                            p2 = ed.GetPoint("Pick 2nd Plane point :").Value;
                            p3 = ed.GetPoint("Pick 3rd Plane point :").Value;
                            Plane sPlane = new Plane(p1, p2, p3);

                            Solid3d solEnt = tr.GetObject(objId, OpenMode.ForRead) as Solid3d;
                            Region reg = solEnt.GetSection(sPlane);
                            btr.AppendEntity(reg);
                            tr.AddNewlyCreatedDBObject(reg, true);
  • Hi Konstantin,

    many thanks for your advice. Thanks to it I managed to get it work.

    Best regards

    Jiri
This discussion has been closed.