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

GetIntersectWith ( ) without drawing entities?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
joantopo
559 Views, 3 Replies

GetIntersectWith ( ) without drawing entities?

Hi.

I have a polyline in my drawing and I have to repeat a lot of times the operation to create a line and find out the intersection point with the pokyline.

RIght now, I create the line and then I erase it .   entity.Erase ( )

 

The issue is I want to avoid this step ( create the line and then erase it) because I said, maybe my command needs to do this operation thousands of times.

 

So, what could I do?  maybe with "drawable" objects...although I have never used them.

 

Thanks in advance.

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
3 REPLIES 3
Message 2 of 4

Hi,

 

Try modify the line (set new start and end point of the line) instead of erase and recreating the new entity.



Virupaksha Aithal KM
Developer Technical Services
Autodesk Developer Network

Message 3 of 4
Anonymous
in reply to: joantopo

You don't have to add the Line object to the database to find the intersection... this will save lot of time and you won't need to erase it.

Just create the object in memory, even reusing the same symbol if you want, but don't add it to the transaction and to the database.

 

Edit: I see now you want to use the IntersectWith() function, that require an ObjectID... maybe you can work in 2D using the Line2d.IntersectWith() function. Here a C# function that will return an array of 2D points:

Later you can convert to 3D using the polyline Plane, if you need it.

 

        public static Point2d[] PLineGetIntersection(Polyline p, Line2d vector)
        {
            if (p == null) return null;
            if (vector == null) return null;

            List<Point2d> vp = new List<Point2d>();

            Point2d[] result = null;
            Tolerance t = new Tolerance(0.1, 0.1);

            for (int i = 0; i < p.NumberOfVertices; i++)
            {
                result = null;
                switch (p.GetSegmentType(i))
                {
                    case SegmentType.Line:
                        LineSegment2d lp = p.GetLineSegment2dAt(i);
                        result = lp.IntersectWith(vector, t);
                        break;

                    case SegmentType.Arc:
                        CircularArc2d ap = p.GetArcSegment2dAt(i);
                        result = ap.IntersectWith(vector, t);
                        break;
                }

                // add partial results to final list
                if (result != null) vp.AddRange(result);
            }

            // convert list to Array as return value
            result = null;
            if (vp.Count > 0) result = vp.ToArray();

            return result;
        }

 

Message 4 of 4
joantopo
in reply to: Anonymous

I did such as @Virupaksha_aithal said, so now I create the line just once and finally I remove it.

 

However, I have noticed that actually this is not the issue about taking a lot of time. The issue is the "Surface.GetIntersectionPoint( ) method (C3D API) where I need to find the intersection of my sight to the surface and my surface has a huge amount of TIN triangles. In addition, I do this iteration every 2 meters.

 

My idea is increasing this first iteration , for example every 20 meters and then apply a sub-iteration (every 1 meter) once there is no solution (intersection has found).

 

Thanks for all.

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report