8 Jul 22:15 avatar

Примеры кода

habrahabr.ru/post/249015/

habrahabr.ru/post/259303/

through-the-interface.typepad.com/through_the_interface/2006/09/working_with_sp.html

arxdummies.blogspot.ru/2005/02/class-2-autocads-database.html

sites.google.com/site/bushmansnetlaboratory/translate-manual/sozdanie-i-redaktirovanie-obektov-autocad/rabota-s-vybrannymi-naborami

Доступ к базе данных открытого документа и итерирование по пространству модели с выводом в консоль типов всех объектов




			//// Open the model space block table record.
			////
			AcDbBlockTable *pBlkTbl;
			acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl, AcDb::kForRead);

			AcDbBlockTableRecord *pBlkTblRcd;
			pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd,
				AcDb::kForRead);
			pBlkTbl->close();

			AcDbBlockTableRecordIterator *pBlkTblRcdItr;
			pBlkTblRcd->newIterator(pBlkTblRcdItr);

			AcDbEntity *pEnt;
			for (pBlkTblRcdItr->start(); !pBlkTblRcdItr->done(); pBlkTblRcdItr->step())
			{
				pBlkTblRcdItr->getEntity(pEnt,
					AcDb::kForRead);
				acutPrintf(L"\n--  %s", 
					(pEnt->isA())->name());
				pEnt->close();
			}
			pBlkTblRcd->close();
			delete pBlkTblRcdItr;
			
			acedRetVoid();	





public void CreateSolidsAndCheckIntersect() // This method can have any name 
        {

            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

        
            bool intersect = false;



            Transaction tr =
              db.TransactionManager.StartTransaction();
            using (tr)
            {
                // Create the solid and set the history flag

                Solid3d sol = new Solid3d();
          

                // ранее здесь находился код создания цилиндра
                sol1.CreateBox(100.0, 500.0, 35.0);

         

                // Add the Solid3d to the modelspace

                BlockTable bt = (BlockTable)tr.GetObject(
                    db.BlockTableId,
                    OpenMode.ForRead
                  );

                BlockTableRecord ms = (BlockTableRecord)tr.GetObject(
                    bt[BlockTableRecord.ModelSpace],
                    OpenMode.ForWrite
                  );

                ms.AppendEntity(sol1);
   

                tr.AddNewlyCreatedDBObject(sol1, true);

                // And transform it to the selected point
                // основной метод для перемещения объектов
                sol1.TransformBy(
                  Matrix3d.Displacement(pt - Point3d.Origin)
                );

                Point3dCollection pts = new Point3dCollection();


                Plane one = new Plane(Point3d.Origin, new Vector3d(5d,0d,0d), new Vector3d(0d, 0d, 5d));


                //ent.BoundingBoxIntersectWith(ent1, Intersect.OnBothOperands, pts, IntPtr.Zero, IntPtr.Zero);

                Point3d thePoint = Point3d.Origin;


                Autodesk.AutoCAD.BoundaryRepresentation.Brep brepEnt = new Brep(sol1);
                PointContainment pointCont;
                brepEnt.GetPointContainment(thePoint, out pointCont);
                if (pointCont == PointContainment.Inside)
                {
                    intersect = true;
                }


                foreach (ObjectId id in ms)
                {
                    DBObject obj = (DBObject) tr.GetObject(id, OpenMode.ForRead);


                    Entity ent = (Entity)obj;
                    
                    ed.WriteMessage("\nType:" + ent.GetType().ToString());

                }






                Point3d p3dMax = sol1.GeometricExtents.MaxPoint; //получаем самую верхнюю точку bounding box

                Point3d p3dMin = sol1.GeometricExtents.MinPoint; //получаем самую нижнюю точку bounding box

                Brep brep1 = new Brep(sol1); //получаем B-Rep - представление объекта

                BrepVertexCollection vert_coll = brep1.Vertices; //Получаем массив вершин

                List<Autodesk.AutoCAD.BoundaryRepresentation.Vertex> vert_list = new List<Autodesk.AutoCAD.BoundaryRepresentation.Vertex>();

                foreach (Autodesk.AutoCAD.BoundaryRepresentation.Vertex vert in vert_coll)
                {

                    vert_list.Add(vert);

                }



                Document document = Application.DocumentManager.MdiActiveDocument;
                Editor editor;
                if (document != null)
                {


                    editor = document.Editor;
                    editor.WriteMessage("Min Point is" + p3dMin.ToString());

                    editor.WriteMessage("Intersect" + intersect.ToString());

                }

                tr.Commit();
            }

        }


ИТЕРИРОВАНИЕ ПО ВСЕМ СЛОЯМ С ПОЛУЧЕНИЕМ ОБЪЕКТОВ КАЖДОГО СЛОЯ

through-the-interface.typepad.com/through_the_interface/2008/05/finding-all-the.html
6 Jan 12:45 avatar

Environment Variables

To run any Open CASCADE Technology application you need to set the environment variables.

On Windows

You can define the environment variables with env.bat script located in the $CASROOT folder. This script accepts two arguments to be used: the version of Visual Studio (vc8 – vc12) and the architecture (win32 or win64).

The additional environment settings necessary for compiling OCCT libraries and samples by Microsoft Visual Studio can be set using script custom.bat located in the same folder. You might need to edit this script to correct the paths to third-party libraries if they are installed on your system in a non-default location.

Script msvc.bat can be used with the same arguments for immediate launch of Visual Studio for (re)compiling OCCT.

On Unix

If OCCT was built by Code::Blocks, you can define the environment variables with env_cbp.sh or custom_cbp.sh script.

If OCCT was built by Automake, you can define the environment variables with env_amk.sh or custom_amk.sh script.

The scripts are located in the OCCT root folder.

Description of system variables:

CASROOT is used to define the root directory of Open CASCADE Technology;
PATH is required to define the path to OCCT binaries and 3rdparty folder;
LD_LIBRARY_PATH is required to define the path to OCCT libraries (on UNIX platforms only);
MMGT_OPT (optional) if set to 1, the memory manager performs optimizations as described below; if set to 2, Intel ® TBB optimized memory manager is used; if 0 (default), every memory block is allocated in C memory heap directly (via malloc() and free() functions). In the latter case, all other options starting with MMGT, except MMGT_CLEAR, are ignored;
MMGT_CLEAR (optional) if set to 1 (default), every allocated memory block is cleared by zeros; if set to 0, memory block is returned as it is;
MMGT_CELLSIZE (optional) defines the maximal size of blocks allocated in large pools of memory. Default is 200;
MMGT_NBPAGES (optional) defines the size of memory chunks allocated for small blocks in pages (operating-system dependent). Default is 10000;
MMGT_THRESHOLD (optional) defines the maximal size of blocks that are recycled internally instead of being returned to the heap. Default is 40000;
MMGT_MMAP (optional) when set to 1 (default), large memory blocks are allocated using memory mapping functions of the operating system; if set to 0, they will be allocated in the C heap by malloc();
CSF_LANGUAGE (optional) defines default language of messages;
CSF_DEBUG (optional, Windows only): if defined then a diagnostic message is displayed in case of an exception;
CSF_DEBUG_BOP (optional): if defined then it should specify directory where diagnostic data on problems occured in Boolean operations will be saved;
CSF_MDTVTexturesDirectory defines the directory for available textures when using texture mapping;
CSF_ShadersDirectory defines the directory for GLSL programs (required for 3D viewer to work);
CSF_UnitsDefinition and CSF_UnitsLexicon should define paths to resource files Lexi_Expr.dat and Units.dat, respectively (required for support of measurement units);
CSF_SHMessage defines the path to the messages file for ShapeHealing;
CSF_XSMessage defines the path to the messages file for STEP and IGES translators;
CSF_StandardDefaults, CSF_StandardLiteDefaults*, **CSF_XCAFDefaults, and CSF_PluginDefaults define paths to directory where configuration files for OCAF persistence are located (required for open/save operations with OCAF documents);
CSF_IGESDefaults and CSF_STEPDefaults (optional) define paths to directory where resource files of IGES and STEP translators are located;
CSF_XmlOcafResource is required in order to set the path to XSD resources, which defines XML grammar.
CSF_MIGRATION_TYPES is required in order to read documents that contain old data types, such as TDataStd_Shape;
12 Dec 00:35 avatar

How to Build an simple Opencascade Program using Visual C++

18 Oct 17:18 avatar

Перевод документации OpenCascade. "Getting started"

www.opencascade.com/doc/occt-7.0.0/overview/html/index.html#OCCT_OVW_SECTION_7

Начало


Draw Test Harness («Тестовая упряжка»)


Draw это командный интерпретатор, основанный на TCL. а также графическая система, используемая для тестирования и демонстрации библиотек моделирования OCCT.
Draw может использоваться для интерактивного создания, отображения и модификации таких объектов как кривые линии (curves), поверхности (surfaces) и топологические объекты (topological shapes).

15 Oct 14:36 avatar

OCCT CSharp sample

window=tile
Отображение переключено в режим «Tile» (Window-->Tile)