Get Attribute from Layer, how?

Hello,

based on that topic:

how can i extent my infos from the .dwg ?

i want to get “Bezeichnung” - it is the BlockName.

grafik
:face_with_monocle:

KR

Andreas

Hola amigo @Draxl_Andreas como estas?? this is a hard nut to crack my friend, there is a way with open mep for .dwg attached to a revit file i let you the link, in the default dynamo de C3D even with packages only you can get the anonymous name, with Civil3D Toolkit you can have at least the handle, better than the anonymous name!! (Version 2023)

2 Likes

@gilberto.arechigaiba ,

Estoy bien, mi jefe dijo " tu eres mastro de MEP…", yo dijo “desde cuando?” , “…desde ahorita”

sadly it is closed that means, i can maybe find in github something… Muchas gracias

thats realy a progress

i can get Name, U253

i just need Atribute or Blockname like in revit(pic)

KR

Andreas

1 Like

@Draxl_Andreas

1 Like

are you need the c# cod ?

1 Like

@RMohareb ,

i prefer python, but i can traduce C# to python very well. I work on a PyRevit implementation.

when you have a hint, let me know :wink:

KR

Andreas

I work in Revit 2022 …still … hmmm @RMohareb

1 Like

for revit 2022

1 Like

Glad to help amigo Draxl, i’m also stock whit a similar situation since a couple months, amigo @RMohareb any chance of we can make work this .dll in dynamo for C3D? i’m not so strong in programation either!! :woozy_face: couldn’t select the blocks by the real name is a strong handycap for users!

1 Like

Brimoahreb Pak is Revit Pak… You can not load into dynamo C3d
image

In your case, you can use this node in Open MEP package : Class BlockReference | Open MEP

GetAttributes

3 Likes

Amigo @chuongmep buenas. you are: “El Chingon” :cowboy_hat_face: ; last time i didn’t make it work the .msi don’t install automatically the folder in the current Dynamo C3D, this time I search the folder an place it in the current version, it works, tank you man for real!!

1 Like

Hi,

An alternative is to convert the dwg to dxf then read the properties with a library like

an example with netDxf


# Load the Python Standard and DesignScript Libraries
import sys
import clr
import System
clr.AddReference('ProtoGeometry')
import Autodesk.DesignScript.Geometry as DS

# Import necessary Revit libraries
clr.AddReference('RevitAPI')
import Autodesk
import Autodesk.Revit.DB as DB

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

# Import DynamoServices for workspace information
clr.AddReference("DynamoServices")
from Dynamo.Events import *

# Access to the current Dynamo workspace path (e.g., location of the opened dynamo file)
currentWorkspacePath = ExecutionEvents.ActiveSession.CurrentWorkspacePath
currentWorkspace = ExecutionEvents.ActiveSession.CurrentWorkspacePath
directoryScript = System.IO.Path.GetDirectoryName(currentWorkspace)
sys.path.append(directoryScript)

# Import netDxf library for working with DXF files
clr.AddReference('netDxf.netstandard')
import netDxf
from netDxf import *
from netDxf.Blocks import *
from netDxf.Collections import *
from netDxf.Entities import *
from netDxf.Tables import *

# Define a class for working with DXF files
class DXF_Utils():
    def __init__(self, outDxfpath):
        self.outDxfpath = outDxfpath
        self._doc_dxf = None
        # Check if the DXF file exists, and if so, load it
        if System.IO.File.Exists(self.outDxfpath):
            # Initialize Document
            self._doc_dxf = DxfDocument()
            self._doc_dxf = netDxf.DxfDocument.Load(self.outDxfpath)

    # Method to get all insert blocks with a specific attribute tag
    def GetAll_Insert_Blocks(self, searchTag=""):
        out = []
        for e in self._doc_dxf.Inserts:
            # Check if the block has the specified attribute tag
            att_Test = e.Attributes.AttributeWithTag(searchTag)
            if att_Test is not None:
                # Create a DesignScript point from the DXF insert position
                pt = DS.Point.ByCoordinates(e.Position.X, e.Position.Y, e.Position.Z)
                out.append([e.Block.Name, pt, att_Test.Tag, att_Test.Value])
        return out

# Unwrap the imported DXF element
import_inst_dxf = UnwrapElement(IN[0])
cadLinkType = doc.GetElement(import_inst_dxf.GetTypeId())

# Check if the linked CAD file is a DXF file
if cadLinkType.Name.endswith(".dxf"):
    # Get the file path of the linked DXF file
    ext_fileRef = cadLinkType.GetExternalFileReference()
    modelpath_dxf = ext_fileRef.GetAbsolutePath()
    dxf_filepath = DB.ModelPathUtils.ConvertModelPathToUserVisiblePath(modelpath_dxf)

    # Create an instance of DXF_Utils class and get all insert blocks with a specific attribute tag
    obj_dxf = DXF_Utils(dxf_filepath)
    OUT = obj_dxf.GetAll_Insert_Blocks(searchTag="TEST")
6 Likes

Update: I made an script that works as Data Extraction with steroids: is to obtain position data, dynamic parameters (DP) with their values and attributes (AT) with their values, it generates an Excel file ([dwg file name + -DP OR -AT]) as appropriate, each sheet is a type of Block with its instances listed with its Attribute or Dynamic parameter values, Thanks again amigo @chuongmep i was 4 months blocked.

1 Like

@RMohareb

i developed a bit we use GIT. I learn C#. It is easy to traduce to python also via ChatGPT.
can i see the code on Github?

@Draxl_Andreas :love_you_gesture: :cowboy_hat_face:


using System;
//using Autodesk.AutoCAD.Interop;
using System.Collections.Generic;


using Autodesk.AutoCAD.ApplicationServices;

//using Autodesk.AutoCAD.Interop.Common;
using Point = Autodesk.DesignScript.Geometry.Point;


using Autodesk.DesignScript.Runtime;


using Linee = Autodesk.DesignScript.Geometry.Line;
using ArcE = Autodesk.DesignScript.Geometry.Arc;
using PolycurveE = Autodesk.DesignScript.Geometry.PolyCurve;
using PointE = Autodesk.DesignScript.Geometry.Point;
using PolygonE = Autodesk.DesignScript.Geometry.Polygon;
using SurfaceE = Autodesk.DesignScript.Geometry.Surface;

using CircleE = Autodesk.DesignScript.Geometry.Circle;

using NurbsCurveE= Autodesk.DesignScript.Geometry.NurbsCurve;

//using Autodesk.AutoCAD.DatabaseServices;

//using Autodesk.AutoCAD.ApplicationServices;
//using Autodesk.AutoCAD.Interop;

//using System;
//using Autodesk.AutoCAD.Interop;
//using Autodesk.AECC.Interop.UiRoadway;
//using System.Collections.Generic;
//using System;
//using System.IO;
//using System.Text;
//using System.Security.Principal;
//using Autodesk.AutoCAD.ApplicationServices;
//using Autodesk.AutoCAD.DatabaseServices;
//using Autodesk.AutoCAD.Interop.Common;
//using Point = Autodesk.DesignScript.Geometry.Point;



//using Autodesk.AutoCAD.Runtime;
//using Autodesk.AutoCAD.ApplicationServices;
//using Autodesk.AutoCAD.DatabaseServices;
//using Autodesk.AutoCAD.PlottingServices;



//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

//using System.Runtime;
//using System.Runtime.InteropServices;

//using Autodesk.AutoCAD.Interop;
//using Autodesk.AutoCAD.Interop.Common;
//using Autodesk.AECC.Interop.UiRoadway;
//using Autodesk.AECC.Interop.Roadway;
//using Autodesk.AECC.Interop.UiLand;
//using Autodesk.AECC.Interop.Land;
//using System.Reflection;

//using Autodesk.DesignScript.Runtime;

//using Autodesk.DesignScript.Geometry;

//using System.Xml;
//using System.Globalization;
//using Application = Autodesk.AutoCAD.ApplicationServices.Application;
//using Autodesk.AutoCAD.EditorInput;
//using Autodesk.AutoCAD.Geometry;

namespace CAD
{

    public class CADApplication
    {

        string m_sAcadProdID = "AutoCAD.Application";


        public dynamic m_oAcadApp = null;
        public dynamic CadAPP = null;
        private Document m_oAeccDoc;
        private dynamic InternalElement;
        private static dynamic acActiveViewport;





        //string m_sAcadProdID = "AutoCAD.Application";
        //public AcadApplication m_oAcadApp = null;
        //public AcadApplication CadAPP = null;
        //private Document m_oAeccDoc;
        //private AcadDocument InternalElement;
        //private static AcRegenType acActiveViewport;







        // Constructor
        public CADApplication()
        {
            this.CadAPP = Get_CAD_Application();

        }


        internal dynamic Get_CAD_Application()
        {

            try

            {
                m_oAcadApp = System.Runtime.InteropServices.Marshal.GetActiveObject(m_sAcadProdID);

            }
            catch (Autodesk.AutoCAD.Runtime.Exception /*ex*/)
            {
                System.Type AcadProg = System.Type.GetTypeFromProgID(m_sAcadProdID);
                m_oAcadApp = System.Activator.CreateInstance(AcadProg, true);
            }


         
                return m_oAcadApp;
            



        }



        public static void Draw_Circle(CADApplication CADApplication, double CenterOfCircle_X = 0, double CenterOfCircle_Y = 0, double CenterOfCircle_Z = 0, double RadiusOfCircle = 0)
        {

            //   Definfing the center point for the circle, in this example, we are using origin(0, 0, 0) as the center of circle.
            double[] CenterOfCircle = new double[3];
            CenterOfCircle[0] = CenterOfCircle_X;
            CenterOfCircle[1] = CenterOfCircle_Y;
            CenterOfCircle[2] = CenterOfCircle_Z;


            //    Adding Circle to the modelspace and getting reference to the circle created.

            CADApplication.CadAPP.ActiveDocument.ModelSpace.AddCircle(CenterOfCircle, RadiusOfCircle);
        }



        public static void Draw_Point(CADApplication CADApplication, double X, double Y, double Z)
        {

            double[] m_point = new double[] { X, Y, Z };
            CADApplication.CadAPP.ActiveDocument.ModelSpace.AddPoint(m_point);

        }



        public static void Draw_Poly_Line(CADApplication CADApplication, IList<double> X, IList<double> Y, IList<double> Z)
        {
            // Definfing the center point for the circle, in this example, we are using origin(0, 0, 0) as the center of circle.

            IList<Point> points = new List<Point>();

            for (int i = 0; i < X.Count; i++)
            {
                points.Add(Point.ByCoordinates(X[i], Y[i], Z[i]));
            }

            //  Adding PolyLine to the modelspace created.
            CADApplication.m_oAcadApp.ActiveDocument.ModelSpace.Add3DPoly(points);
        }


        public static void SendCommand(CADApplication CADApplication, string Command)
        {
            string Finalcommand;
            Finalcommand = Command + "\n";
            CADApplication.m_oAcadApp.ActiveDocument.SendCommand(Finalcommand);
        }

        //public static void SendCommand(CADApplication CADApplication, string Command,string filepath)
        //{

        //    dynamic AcadDoc = CADApplication.m_oAcadApp.Documents.Add();
        //    AcadDoc.Activate();
        //    AcadDoc.Close(false);
        //    string Finalcommand;
        //    Finalcommand = Command + "\n";
        //   // CADApplication.m_oAcadApp.Documents.Open(@"C:\Users\mohareb\Desktop\Drawing1.dwg");

        //    CADApplication.m_oAcadApp.Documents.Open(filepath);
        //    SendCommand(CADApplication, Command);



        //}

        public static void SendCommand(CADApplication CADApplication, string Command, string filepath,bool SaveAndClose)
        {

            dynamic AcadDoc = CADApplication.m_oAcadApp.Documents.Add();
            AcadDoc.Activate();
            AcadDoc.Close(false);

         

            CADApplication.m_oAcadApp.Documents.Open(filepath);
            SendCommand(CADApplication, Command);
            if (SaveAndClose)
            {
                CADApplication.m_oAcadApp.ActiveDocument.Save();
                CADApplication.m_oAcadApp.ActiveDocument.Close();
            }



        }


        public override string ToString()
        {
            return string.Format($"CADApplication (ActiveDocument = {this.m_oAcadApp.ActiveDocument.Name})");
        }


        [MultiReturn(new[] { "PointToPoint", "LineToLine", "ArcTOArc", "CircleToCircle", "PolyCurveToPolyLine", "PolyCurve_3DToPolyLine", "3DFaceToPlygone", "3DFaceToSurface", "MeshToPoint", "BlockInsertionPoint", "BlockRotationt", "BlockName" , "SplineToNurbsCurve" })] // DesignScript.Runtime   
        public static Dictionary<string, object> Cad_Geometry(CADApplication CADApplication, string LayerName)
        {


            //  PolycurveE P3d = null;

            IList<Linee> LineList = new List<Linee>();

            IList<CircleE> CircleList = new List<CircleE>();
            IList<ArcE> ArcList = new List<ArcE>();
            IList<Point> PointList = new List<Point>();
            IList<PolycurveE> PolycurveList = new List<PolycurveE>();
            IList<PolycurveE> Polycurve3DList = new List<PolycurveE>();
            IList<PolygonE> plygone3DList = new List<PolygonE>();
            IList<SurfaceE> SurfaceList = new List<SurfaceE>();

            var NurbsCurveList = new List<NurbsCurveE>();


            IList<Double> XY = new List<Double>();
            IList<Double> XYZ = new List<Double>();
            IList<Double> Rotation = new List<Double>();
            IList<string> BlockName = new List<string>();


            IList<PointE> pointToSpline = new List<PointE>();
            IList<PointE> pointToPolyLine = new List<PointE>();
            IList<PointE> pointToface = new List<PointE>();
            IList<PointE> PointToMesh = new List<PointE>();
            IList<PointE> BlockPoint = new List<PointE>();
            IList<IList<PointE>> PointToMeshout = new List<IList<PointE>>();
            IList<IList<PointE>> BlockPointhout = new List<IList<PointE>>();


            // select all element in the layer

            short[] oFilter = new short[] { 8 };
            object[] oData = new object[] { LayerName };

            dynamic objSS = null;
            try
            {

                objSS = CADApplication.m_oAcadApp.ActiveDocument.SelectionSets.item("ssw1");
                objSS.Clear();


                objSS.Select(Autodesk.AutoCAD.Interop.Common.AcSelect.acSelectionSetAll, null, null, oFilter, oData);

            }
            catch
            {
                objSS = CADApplication.m_oAcadApp.ActiveDocument.SelectionSets.Add("ssw1");

                objSS.Clear();

                objSS.Select(Autodesk.AutoCAD.Interop.Common.AcSelect.acSelectionSetAll, null, null, oFilter, oData);

            }




            foreach (var obj in objSS)





            // foreach (var obj in document.ModelSpace)
            {

                //////////////////////////////////////////////////////////////////////

                if (obj.EntityName == "AcDbSpline")
                {
                    if (obj.Layer == LayerName)
                    {


                        foreach (double item in obj.ControlPoints)
                        {
                            XYZ.Add(item);
                        }


                        for (int i = 0; i < XYZ.Count; i += 3)
                        {
                            pointToSpline.Add(Point.ByCoordinates(XYZ[i], XYZ[i + 1], XYZ[i + 2]));
                        }


                        if (obj.Closed)
                        {


                            NurbsCurveList.Add( Autodesk.DesignScript.Geometry.NurbsCurve.ByControlPoints(pointToSpline, obj.Degree, true));

                          //  PolycurveList.Add(PolycurveE.ByPoints(pointToPolyLine, true));
                        }
                        else
                        {
                            var ss = Autodesk.DesignScript.Geometry.NurbsCurve.ByControlPoints(pointToSpline, obj.Degree, false);
                            NurbsCurveList.Add( Autodesk.DesignScript.Geometry.NurbsCurve.ByControlPoints(pointToSpline, obj.Degree, false));
                        }



                        //foreach (double item in obj.FitPoints)
                        //{
                        //    XY.Add(item);
                        //}


                        XYZ.Clear();

                    }
                }


                //////////////////////////////////////////////////////////////////////

                if (obj.EntityName == "AcDbPoint")
                {

                    foreach (double item in obj.Coordinates)
                    {
                        XYZ.Add(item);
                    }

                    if (obj.Layer == LayerName)
                    {
                        PointList.Add(PointE.ByCoordinates(XYZ[0], XYZ[1], XYZ[2]));
                    }


                    XYZ.Clear();

                }

                ////////////////////////////////////////////////////////////////////


                if (obj.EntityName == "AcDbLine")
                {

                    Point StartptDyn = Point.ByCoordinates(obj.StartPoint[0], obj.StartPoint[1], obj.StartPoint[2]);
                    Point EndptDyn = Point.ByCoordinates(obj.EndPoint[0], obj.EndPoint[1], obj.EndPoint[2]);
                    Linee L = Linee.ByStartPointEndPoint(StartptDyn, EndptDyn);

                    //if (obj.Layer == LayerName)
                    //{
                    LineList.Add(L);

                    //}
                }

                /////////////////////////////////////////////////////////////////////
                ///

                if (obj.EntityName == "AcDbArc")
                {


                    Point ArcStartptDyn = Point.ByCoordinates(obj.StartPoint[0], obj.StartPoint[1], obj.StartPoint[2]);
                    Point ArcEndptDyn = Point.ByCoordinates(obj.EndPoint[0], obj.EndPoint[1], obj.EndPoint[2]);
                    Point ArcCenterptDyn = Point.ByCoordinates(obj.Center[0], obj.Center[1], obj.Center[2]);
                    ArcE Arc = ArcE.ByCenterPointStartPointEndPoint(ArcCenterptDyn, ArcStartptDyn, ArcEndptDyn);


                    //if (obj.Layer == LayerName)
                    //{
                    ArcList.Add(Arc);
                    //}
                }
                ////////////////////////////////////////////////////////////////////////////

                if (obj.EntityName == "AcDbCircle")
                {

                    Point Centerpoint = Point.ByCoordinates(obj.Center[0], obj.Center[1], obj.Center[2]);

                    CircleE C = CircleE.ByCenterPointRadius(Centerpoint, obj.Radius);

                    //if (obj.Layer == LayerName)
                    //{
                    CircleList.Add(C);
                    //}
                }
                ///////////////////////////////////////////////////
                if (obj.EntityName == "AcDbPolyline")
                {
                    double Z = obj.Elevation;

                    foreach (double item in obj.Coordinates)
                    {
                        XY.Add(item);
                    }

                    for (int i = 0; i < XY.Count; i += 2)
                    {
                        pointToPolyLine.Add(Point.ByCoordinates(XY[i], XY[i + 1], Z));
                    }

                    if (obj.Closed)
                    {
                        PolycurveList.Add(PolycurveE.ByPoints(pointToPolyLine, true));
                    }
                    else
                    {
                        PolycurveList.Add(PolycurveE.ByPoints(pointToPolyLine));
                    }




                    //if (obj.Layer == LayerName)
                    //{

                    //}

                    XY.Clear();
                    pointToPolyLine.Clear();
                }


                ////////////////////////////////////////////////


                if (obj.EntityName == "AcDb3dPolyline")
                {
                    foreach (double item in obj.Coordinates)
                    {
                        XYZ.Add(item);
                    }

                    for (int i = 0; i < XYZ.Count; i += 3)
                    {
                        pointToPolyLine.Add(Point.ByCoordinates(XYZ[i], XYZ[i + 1], XYZ[i + 2]));
                    }

                    if (true)
                    {

                    }

                    if (obj.Closed)
                    {

                        Polycurve3DList.Add(PolycurveE.ByPoints(pointToPolyLine, true));



                    }
                    else
                    {
                        Polycurve3DList.Add(PolycurveE.ByPoints(pointToPolyLine));

                    }





                    //if (obj.Layer == LayerName)
                    //{
                    //   Polycurve3DList.Add(P3d);
                    //}

                    XYZ.Clear();
                    pointToPolyLine.Clear();
                }

                ////////////////////////////////////////////////////////////////
                ///

                ///        //case Acad3DFace Face:
                if (obj.EntityName == "AcDbFace")
                {
                    foreach (double item in obj.Coordinates)
                    {
                        XYZ.Add(item);
                    }

                    for (int i = 0; i < XYZ.Count; i += 3)
                    {
                        pointToface.Add(Point.ByCoordinates(XYZ[i], XYZ[i + 1], XYZ[i + 2]));
                    }


                    //if (obj.Layer == LayerName)
                    //{
                    plygone3DList.Add(PolygonE.ByPoints(pointToface));


                    SurfaceList.Add(SurfaceE.ByPatch(PolygonE.ByPoints(pointToface)));
                    //}

                    XYZ.Clear();
                    pointToface.Clear();

                }
                ///////////////////////////////////////////
                ///
                ////////////////////////////////////////////////

                if (obj.EntityName == "AcDbSubDMesh")
                {
                    foreach (double item in obj.Coordinates)
                    {
                        XYZ.Add(item);
                    }




                    for (int i = 0; i < XYZ.Count; i += 3)
                    {
                        PointToMesh.Add(PointE.ByCoordinates(XYZ[i], XYZ[i + 1], XYZ[i + 2]));
                    }

                    //if (obj.Layer == LayerName)
                    //{


                    var object2 = new List<PointE>(PointToMesh);

                    PointToMeshout.Add(object2);
                    //}


                    XYZ.Clear();
                    PointToMesh.Clear();


                }

                //////////////////////////////////////////
                ///

                if (obj.EntityName == "AcDbBlockReference")
                {
                    foreach (double item in obj.InsertionPoint)
                    {
                        XYZ.Add(item);
                    }



                    for (int i = 0; i < XYZ.Count; i += 3)
                    {
                        BlockPoint.Add(PointE.ByCoordinates(XYZ[i], XYZ[i + 1], XYZ[i + 2]));
                    }

                    //if (obj.Layer == LayerName)
                    //{
                    Double DRotation = obj.Rotation;
                    string Srting_Block = obj.Name;
                    Rotation.Add(DRotation/0.0174532925199432958);
                    BlockName.Add(Srting_Block);

                    var object2Block = new List<PointE>(BlockPoint);

                    BlockPointhout.Add(object2Block);
                    //}


                    XYZ.Clear();
                    BlockPoint.Clear();


                }
                /////////////////
                ///


                //  switch (obj)
                //       {


                //////////////////point
                //case AcadPoint Po:

                //    foreach (double item in Po.Coordinates)
                //    {
                //        XYZ.Add(item);
                //    }

                //    if (Po.Layer == LayerName)
                //    {
                //        PointList.Add(PointE.ByCoordinates(XYZ[0], XYZ[1], XYZ[2]));
                //    }


                //    XYZ.Clear();

                //    break;
                ////////////////Line
                //  case AcadLine LL:
                //case AcadLine LL:


                //    Point StartptDyn = Point.ByCoordinates(LL.StartPoint[0], LL.StartPoint[1], LL.StartPoint[2]);
                //    Point EndptDyn = Point.ByCoordinates(LL.EndPoint[0], LL.EndPoint[1], LL.EndPoint[2]);
                //    Linee L = Linee.ByStartPointEndPoint(StartptDyn, EndptDyn);

                //    if (LL.Layer == LayerName)
                //    {
                //        LineList.Add(L);
                //    }
                //    break;
                ///////// Arc
                //case AcadArc Ar:


                //    Point ArcStartptDyn = Point.ByCoordinates(Ar.StartPoint[0], Ar.StartPoint[1], Ar.StartPoint[2]);
                //    Point ArcEndptDyn = Point.ByCoordinates(Ar.EndPoint[0], Ar.EndPoint[1], Ar.EndPoint[2]);
                //    Point ArcCenterptDyn = Point.ByCoordinates(Ar.Center[0], Ar.Center[1], Ar.Center[2]);
                //    ArcE Arc = ArcE.ByCenterPointStartPointEndPoint(ArcCenterptDyn, ArcStartptDyn, ArcEndptDyn);


                //    if (Ar.Layer == LayerName)
                //    {
                //        ArcList.Add(Arc);
                //    }


                //    break;


                ////////////////Circle
                //case AcadCircle Circl:



                //    Point Centerpoint = Point.ByCoordinates(Circl.Center[0], Circl.Center[1], Circl.Center[2]);



                //    if (Circl.Layer == LayerName)
                //    {
                //        CircleList.Add(CircleE.ByCenterPointRadius(Centerpoint, Circl.Radius));
                //    }
                //    break;

                //////polyline

                //case AcadLWPolyline Poly:


                //    double Z = Poly.Elevation;

                //    foreach (double item in Poly.Coordinates)
                //    {
                //        XY.Add(item);
                //    }

                //    for (int i = 0; i < XY.Count; i += 2)
                //    {
                //        pointToPolyLine.Add(Point.ByCoordinates(XY[i], XY[i + 1], Z));
                //    }


                //    if (Poly.Layer == LayerName)
                //    {
                //        PolycurveList.Add(PolycurveE.ByPoints(pointToPolyLine));
                //    }

                //    XY.Clear();
                //    pointToPolyLine.Clear();
                //    break;

                ///////////////////polyline3d
                //case Acad3DPolyline Poly3d:

                //    foreach (double item in Poly3d.Coordinates)
                //    {
                //        XYZ.Add(item);
                //    }

                //    for (int i = 0; i < XYZ.Count; i += 3)
                //    {
                //        pointToPolyLine.Add(Point.ByCoordinates(XYZ[i], XYZ[i + 1], XYZ[i + 2]));
                //    }


                //    if (Poly3d.Layer == LayerName)
                //    {
                //        Polycurve3DList.Add(PolycurveE.ByPoints(pointToPolyLine));
                //    }

                //    XYZ.Clear();
                //    pointToPolyLine.Clear();
                //    break;


                ///////////////////////3dface                 
                //case Acad3DFace Face:

                //    foreach (double item in Face.Coordinates)
                //    {
                //        XYZ.Add(item);
                //    }

                //    for (int i = 0; i < XYZ.Count; i += 3)
                //    {
                //        pointToface.Add(Point.ByCoordinates(XYZ[i], XYZ[i + 1], XYZ[i + 2]));
                //    }


                //    if (Face.Layer == LayerName)
                //    {
                //        plygone3DList.Add(PolygonE.ByPoints(pointToface));


                //        SurfaceList.Add(SurfaceE.ByPatch(PolygonE.ByPoints(pointToface)));
                //    }

                //    XYZ.Clear();
                //    pointToface.Clear();
                //    break;




                ///////////////////////Mesch                
                //case AcadSubDMesh MeshD:

                //    foreach (double item in MeshD.Coordinates)
                //    {
                //        XYZ.Add(item);
                //    }




                //    for (int i = 0; i < XYZ.Count; i += 3)
                //    {
                //        PointToMesh.Add(PointE.ByCoordinates(XYZ[i], XYZ[i + 1], XYZ[i + 2]));
                //    }

                //    if (MeshD.Layer == LayerName)
                //    {


                //        var object2 = new List<PointE>(PointToMesh);

                //        PointToMeshout.Add(object2);
                //    }


                //    XYZ.Clear();
                //    PointToMesh.Clear();
                //    break;






                ///////////////////////Block               
                //case AcadBlockReference Blockk:

                //    foreach (double item in Blockk.InsertionPoint)
                //    {
                //        XYZ.Add(item);
                //    }



                //    for (int i = 0; i < XYZ.Count; i += 3)
                //    {
                //        BlockPoint.Add(PointE.ByCoordinates(XYZ[i], XYZ[i + 1], XYZ[i + 2]));
                //    }

                //    if (Blockk.Layer == LayerName)
                //    {
                //        Rotation.Add(Blockk.Rotation);
                //        BlockName.Add(Blockk.Name);

                //        var object2Block = new List<PointE>(BlockPoint);

                //        BlockPointhout.Add(object2Block);
                //    }


                //    XYZ.Clear();
                //    BlockPoint.Clear();
                //    break;


                //   }

            }


            GC.Collect();
            GC.WaitForPendingFinalizers();

      
                return new Dictionary<string, object>
                                    {
                                    { "PointToPoint", PointList },
                                    { "LineToLine", LineList },
                                    { "ArcTOArc", ArcList },
                                    { "CircleToCircle", CircleList },
                                    { "PolyCurveToPolyLine", PolycurveList },
                                    { "PolyCurve_3DToPolyLine", Polycurve3DList },
                                    { "3DFaceToPlygone", plygone3DList },
                                    { "3DFaceToSurface", SurfaceList },
                                    { "MeshToPoint", PointToMeshout },
                                    { "BlockInsertionPoint", BlockPointhout },
                                    { "BlockRotationt", Rotation },
                                    { "BlockName", BlockName },

                                     { "SplineToNurbsCurve", NurbsCurveList },
                                    





                                    };
      


        }






    }
}


this code work dynamic (to load my pak with other pak accsess to the same com api)

in your case you do not need to use dynamic you can use convert this code (you will found it comment in my code )
image

it will be better if you will convert it to python (you do not need to use dynamic)

1 Like