I'm working on a project which among other things has to determine the visibility properties of an entity within a block definition.
The task is to determine the maximum drawing extents of a block reference within modelspace, however blocks with multiple visibility states are currently showing up with greater extents due to my code not taking into account the currently selected visibility state.
what I'd like to do is pass a visibility state name to the function, and have it compare each entity it encounters with the state name, and if the entity is not visible in that state, ignore it.
This way I can pass a block name, and visibility state to the function, and it will return the maximum extents of the block in that visibility mode only.
Code fragment below of the function that calculates maximum extents,
the block argument is the block definition in the blockstable used to define the reference being processed.
SubjectDwg is a cheat that allows this script/routine to be processed as part of a batch.
the optional 'view' argument is the visibility state name of the current block reference being processed:
Has anyone got any idea how I can get the conditional statement in the code to recognize the visibility parameter of an entity?
Function GetExtents(Block As AcadBlock, SubjectDwg As AcadDocument, Optional View As String) As Double()
Dim Obj As AcadEntity
Dim MinExt(0 To 1) As Variant 'minimum bounding extents of block
Dim MaxExt(0 To 1) As Variant 'maximum bounding extents of block
Dim ObjMinExt As Variant
Dim ObjMaxExt As Variant
Dim TempArray() As Double
ReDim TempArray(0 To 3)
For Each Obj In Block
Select Case Obj.EntityName
TempArray = GetExtents(SubjectDwg.Blocks.Item(Obj.Name), SubjectDwg)
Case "AcDbPolyline", "AcDbLine", "AcDbArc", "AcDbCircle"
If UCase(Obj.Layer) Like "CENTRELINES" Or UCase(Obj.Layer) Like "*-C" Or UCase(Obj.Layer) Like "*-CLEAR" Then
ElseIf obj.visilitystate <> View then ######################### <= this conditional statement needs to work!
Obj.GetBoundingBox ObjMinExt, ObjMaxExt
If ObjMaxExt(0) > MaxExt(0) Then
MaxExt(0) = ObjMaxExt(0)
If ObjMaxExt(1) > MaxExt(1) Then
MaxExt(1) = ObjMaxExt(1)
If MinExt(0) > ObjMinExt(0) Then
MinExt(0) = ObjMinExt(0)
If MinExt(1) > ObjMinExt(1) Then
MinExt(1) = ObjMinExt(1)
TempArray(0) = MinExt(0)
TempArray(1) = MinExt(1)
TempArray(2) = MaxExt(0)
TempArray(3) = MaxExt(1)
GetExtents = TempArray()