Getsubentitycolor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm having trouble with the method "getsubentitycolor". It throws an exception if a color has not been assigned to the subentity (has color index 257). I'm sorting through all the faces of a brep looking for faces with specific colors and can catch the exceptions but catching all the exceptions seems to be consuming a lot of time. Is there any way to avoid the function throwing an exception? My code is as follows:
'searches solid for all faces with color then sends these out to sense unit faces
Private Sub FindSolidFaces(ByVal searchColor As acDefaultColors)
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Using trans As Transaction = db.TransactionManager.StartTransaction
Dim solColorFaces As New List(Of brFace)
Dim solid As Solid3d = TryCast(trans.GetObject(mMwallSolid.SolidId, OpenMode.ForRead), Solid3d)
Using solidBrep As New Brep(solid)
'cycle through each face of the solid looking for color
For Each Face In solidBrep.Faces
Dim faceId As SubentityId = Face.SubentityPath.SubentId
Dim fceColor As New Color
Try
'this method throws an exception if a non-color is returned which
'will happen for each face that has a color "byEntity"
fceColor = solid.GetSubentityColor(faceId)
Catch ex As Autodesk.AutoCAD.Runtime.Exception
End Try
If fceColor.ColorIndex = searchColor Then
'record the face
solColorFaces.Add(Face)
End If
Next
'send the units out to be analyzed
SenseUnitFaces(trans, checkedUnits, solidBrep, solColorFaces)
End Using 'solidBrep
trans.Commit()
End Using 'trans
End Sub