How to get surface boundary when imported from LandXML using .NET API

How to get surface boundary when imported from LandXML using .NET API

vucic_tamara
Enthusiast Enthusiast
1,132 Views
3 Replies
Message 1 of 4

How to get surface boundary when imported from LandXML using .NET API

vucic_tamara
Enthusiast
Enthusiast

Hello,

 

I have few surfaces in the drawing that are imported from LandXML format. Now I need to write a piece of code in C# that iterates through surfaces and then gets surface borders to do some calculations on them. But the problem is that whatever method I seem to use I get no borders from them. This is what I tried so far:

 

var boundariesDef = surface.BoundariesDefinition;

var borderObjectIds1 = surface.ExtractBorder(SurfaceExtractionSettingsType.Plan);
var borderObjectIds2 = surface.ExtractBorder(SurfaceExtractionSettingsType.Model);
var dbcol = new DBObjectCollection();
surface.Explode(dbcol);

 

And all of the collections are empty.

 

If anyone can give any hint on what to do to get the borders it would be great!

 

Thank you,

Tamara

0 Likes
Accepted solutions (1)
1,133 Views
3 Replies
Replies (3)
Message 2 of 4

Jeff_M
Consultant
Consultant

Can you share the dwg and testable code? I just ran a quick test here and the border extracts as expected.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 3 of 4

vucic_tamara
Enthusiast
Enthusiast
Accepted solution

Hi Jeff,

 

When I prepared a test drawing and extracted sample code as you asked I ran my sample code and everything turned out to work perfect.  All of the methods stated above were returning boundary objects.

Then I started to compare what was different between my original code and the one I prepared as a sample to send you.

I noticed one thing different - I was calling my methods in original code from UI thread, and in my sample code I was calling it via CommandMethod. 

And the important thing I noticed is that I didn't wrap my Civil related code in DocumentLock using statement when calling from UI thread. 

After I wrapped my code like this everything seems to be working right:

 

var doc = ACApplication.DocumentManager.MdiActiveDocument;
using(var dockLock = doc.LockDocument())
{
//Do my surface calculations
}

 

Now it is working so I hope this was the problem. Thank you very much, if you weren't asking for example I would have never figured it.

 

Greetings,

Tamara

0 Likes
Message 4 of 4

Jeff_M
Consultant
Consultant

Glad I was able to help in some way! Thanks for posting your findings.

Jeff_M, also a frequent Swamper
EESignature
0 Likes