Profile Picture

How to find specific NShape ID in a document with lots of shapes?

Posted By Hans Henrik Friis Pedersen... 9 Years Ago

How to find specific NShape ID in a document with lots of shapes?

Author
Message
Hans Henrik Friis Pedersen...
Question Posted 9 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 8 Years Ago
Posts: 28, Visits: 136
Hi,

I'm using the following code to loop through all shape in a document (using 2 nested foreach loops) and locate a shape with a specific ID. Isn't there a easier and more efficient method? A Find method?


    NNodeList nodes = document.Descendants(NFilters.TypeNShape, -1);
             foreach (var shape in nodes)
            {
                foreach (MeasurementPoint _measurementPoint in this._measurementPointList)
                {
                    NShape shp = (NShape)shape;
                    if (shp.Id == _measurementPoint.ID)
                    {
//more code here...


Nevron Support
Posted 9 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 1 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009
You can try the following method:
document.GetElementFromId(_measurementPoint.ID);
Internally it uses a dictionary, so it should be much faster and efficient.


Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic