VB.NET : Problems with Boolean Method from 2012 to 2015

VB.NET : Problems with Boolean Method from 2012 to 2015

Anonymous
Not applicable
356 Views
1 Reply
Message 1 of 2

VB.NET : Problems with Boolean Method from 2012 to 2015

Anonymous
Not applicable

This is my first and most likely not my last post in here ;

 

I'm migrating a .NET application from Autocad2012 to Autocad2015. I have yet to find important incompatibilities except this one right here that is really giving me hard times. Basically, the function used have a Region.Area value modified by the Union transaction but on 2015, that area as an Invalid Input or some reason. 

 

Dim MySSet As AcadSelectionSet = AcadApp.ActiveDocument.SelectionSets.Add("SSet1")
Dim FilterType() As Int16 = {8, 0}
Dim FilterData() As Object = {ProgConfig.ClesLayers.CleRegion & "_" & ProgConfig.ClesLayers.CleCut & "_*", ProgConfig.ClesLayers.CleRegion}
MySSet.Select(AcSelect.acSelectionSetAll, , , FilterType, FilterData)


Dim RegionsDessus As New List(Of AcadRegion)
Dim RegionsDessous As New List(Of AcadRegion)

For Each MyAcadEntity As AcadEntity In MySSet

Dim MyEntityNormal As New NormalVector(MyAcadEntity.Normal)

If ((MyEntityNormal.Rnd_X = NormalDessus.Rnd_X) And (MyEntityNormal.Rnd_Y = NormalDessus.Rnd_Y) And (MyEntityNormal.Rnd_Z = NormalDessus.Rnd_Z)) Then
RegionsDessus.Add(MyAcadEntity)
ElseIf ((MyEntityNormal.Rnd_X = NormalDessous.Rnd_X) And (MyEntityNormal.Rnd_Y = NormalDessous.Rnd_Y) And (MyEntityNormal.Rnd_Z = NormalDessous.Rnd_Z)) Then
RegionsDessous.Add(MyAcadEntity)
End If

Next

MySSet.Clear() : MySSet.Delete()

Dim Regions2Remove As New List(Of AcadRegion)

For RegionCount As Integer = 0 To RegionsDessous.Count - 1

Dim RegionDessous As AcadRegion = RegionsDessous(RegionCount)


Dim Resultat As List(Of AcadRegion) = (From Element In RegionsDessus _
Where (Math.Abs((Element.Area - RegionDessous.Area)) < ProgConfig.AppConfig3.Tolerance01)).ToList


Dim ResultCount As Integer = 0

For ResultCount = 0 To Resultat.Count - 1

Dim RegionTemp As AcadRegion = RegionDessous.Copy
RegionTemp.Boolean(AcBooleanType.acUnion, Resultat(ResultCount).Copy)

Dim AreaDiff As Double = Math.Abs((Resultat(ResultCount).Area - RegionTemp.Area))

RegionTemp.Delete()

0 Likes
357 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

Apparently, you cannot Union 2 regions that has opposite Normals. As i exploded these regions, i figured that the main difference between these 2 were the normals in Z. I added a condition where it checks if the entities have opposite normals. If they do, i simply rotate one 180° and perform the union. 

 

This problem occured only when i upgraded from Autocad2012 to Autocad2015.

 

I posted my answer so that others with the same problem might stumble on it.

0 Likes