View Issue Details

IDProjectCategoryView StatusLast Update
0032511CommunityPRODUCTS:DXF Importpublic2021-08-03 18:14
Reporterlucas_morona_164500 Assigned Togka 
PrioritynormalSeveritymajor 
Status newResolutionopen 
PlatformWindowsOSWindows 10 
Product Version7.3.0 
Summary0032511: DXF Import - OCC import Autocad dimensions lines as shapes
DescriptionCreate an Autocad file and set dimensions in your object, OCC imports this dimensions lines as shapes, I need only shapes from model, not arrow and lines from dimensions.
Steps To ReproduceImport DXF file using the below, DXF import Autocad dimension lines as shapes.



    // To extract name of layers is necessary to have a TDocStd_Document
    Handle(TDocStd_Document) document;
    Handle(XCAFApp_Application) application = XCAFApp_Application::GetApplication();

    // Is necessary create a new document
    application->NewDocument(m_filePath.toLatin1().constData(), document);
    DXFCAFControl_Reader dxfReaderLayer;
    dxfReaderLayer.SetNameMode(true);
    TCollection_AsciiString filePathUtf8(m_filePath.toUtf8().constData());
    dxfReaderLayer.ReadFile(filePathUtf8.ToCString());

    // You must transfer your reader to document
    dxfReaderLayer.Transfer(document);
    TDF_Label rootLabel = document->Main();

    // This object is important to extract layer from DXF
    Handle(XCAFDoc_LayerTool) layerTool = XCAFDoc_DocumentTool::LayerTool(rootLabel);

    // This object is important to extract shapes from layers
    Handle(XCAFDoc_ShapeTool) shapeTool = XCAFDoc_DocumentTool::ShapeTool(rootLabel);

    TDF_ChildIterator it;
    Handle(TDataStd_Name) layerName;
    for (it.Initialize(rootLabel, Standard_True); it.More(); it.Next())
    {
        // Get only the layers attributes
        TDF_Label labelLayer = it.Value();
        layerTool->FindAttribute(TDataStd_Name::GetID(), layerName);
        if (layerTool->IsLayer(labelLayer))
        {
            if (labelLayer.FindAttribute(TDataStd_Name::GetID(), layerName))
            {
                TDF_LabelSequence labelSequence = TDF_LabelSequence();
                layerTool->GetShapesOfLayer(labelLayer, labelSequence);
                // Is necessary to take the layer of any edge
                int numbersOfShapes = labelSequence.Size();
                if (numbersOfShapes > 0)
                {
                    QString layer = QString(TCollection_AsciiString(layerName->Get()).ToCString());

                    for (TDF_LabelSequence::Iterator labelIt(labelSequence); labelIt.More(); labelIt.Next())
                    {
                        TDF_Label shapeLabel = labelIt.Value();
                        TopoDS_Shape layerShape = shapeTool->GetShape(shapeLabel);

                        if (layerShape.IsNull())
                        {
                            continue;
                        }

                        if (TopAbs_VERTEX == layerShape.ShapeType())
                        {
                            insertLayer(layer);
                            insertVisibilityShape(QString(TCollection_AsciiString(layerName->Get()).ToCString()), layerShape);
                            m_numberOfVertices++;
                        }
                        else if (TopAbs_EDGE == layerShape.ShapeType())
                        {
                            insertLayer(layer);
                            insertVisibilityShape(QString(TCollection_AsciiString(layerName->Get()).ToCString()), layerShape);
                            m_numberOfLines++;
                        }
                        else if (TopAbs_WIRE == layerShape.ShapeType())
                        {
                            insertLayer(layer);
                            insertVisibilityShape(QString(TCollection_AsciiString(layerName->Get()).ToCString()), layerShape);
                            m_numberOfWires++;
                        }
                        else if (TopAbs_FACE == layerShape.ShapeType())
                        {
                            insertLayer(layer);
                            insertVisibilityShape(QString(TCollection_AsciiString(layerName->Get()).ToCString()), layerShape);
                            m_numberOfFaces++;
                        }
                        else if (TopAbs_COMPOUND == layerShape.ShapeType())
                        {
                            insertLayer(layer);

                            for (TopExp_Explorer explorer(layerShape, TopAbs_ShapeEnum::TopAbs_WIRE); explorer.More(); explorer.Next())
                            {
                                TopoDS_Wire wire = TopoDS::Wire(explorer.Current());

                                if (!wire.IsNull())
                                {
                                    insertVisibilityShape(QString(TCollection_AsciiString(layerName->Get()).ToCString()), wire);
                                    m_numberOfWires++;
                                }
                            }

                            for (TopExp_Explorer explorer(layerShape, TopAbs_ShapeEnum::TopAbs_FACE); explorer.More(); explorer.Next())
                            {
                                TopoDS_Face face = TopoDS::Face(explorer.Current());

                                if (!face.IsNull())
                                {
                                    insertVisibilityShape(QString(TCollection_AsciiString(layerName->Get()).ToCString()), face);
                                    m_numberOfFaces++;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Additional information
and documentation updates
There is a file in description to do it test.
TagsNo tags attached.
Test case number

Attached Files

  • Dimensions01.dxf (186,243 bytes)

Activities

lucas_morona_164500

2021-08-03 17:40

reporter  

Dimensions01.dxf (186,243 bytes)

Issue History

Date Modified Username Field Change
2021-08-03 17:40 lucas_morona_164500 New Issue
2021-08-03 17:40 lucas_morona_164500 Assigned To => gka
2021-08-03 17:40 lucas_morona_164500 File Added: Dimensions01.dxf
2021-08-03 18:12 kgv Summary OCC import Autocad dimensions lines as shapes => DXF Export - OCC import Autocad dimensions lines as shapes
2021-08-03 18:14 kgv Summary DXF Export - OCC import Autocad dimensions lines as shapes => DXF Import - OCC import Autocad dimensions lines as shapes