VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

accessing Visibility properties in block definition

1 REPLY 1
Reply
Message 1 of 2
GilesPhillips
937 Views, 1 Reply

accessing Visibility properties in block definition

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:

 

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
            Case "AcDbTable"
                'ignore
            Case "AcDbBlockReference"
                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
                 'ignore

                ElseIf obj.visilitystate <> View then '######################### <= this conditional statement needs to work!

                 'ignore
                Else
                    Obj.GetBoundingBox ObjMinExt, ObjMaxExt
                    If ObjMaxExt(0) > MaxExt(0) Then
                        MaxExt(0) = ObjMaxExt(0)
                    End If
                    If ObjMaxExt(1) > MaxExt(1) Then
                        MaxExt(1) = ObjMaxExt(1)
                    End If
                    If MinExt(0) > ObjMinExt(0) Then
                        MinExt(0) = ObjMinExt(0)
                    End If
                    If MinExt(1) > ObjMinExt(1) Then
                        MinExt(1) = ObjMinExt(1)
                    End If
                End If
        End Select
Next Obj
TempArray(0) = MinExt(0)
TempArray(1) = MinExt(1)
TempArray(2) = MaxExt(0)
TempArray(3) = MaxExt(1)

GetExtents = TempArray()
        
End Function


Has anyone got any idea how I can get the conditional statement in the code to recognize the visibility parameter of an entity?


thanks

G

ACad, MEP, Revit, 3DS Max
1 REPLY 1
Message 2 of 2
norman.yuan
in reply to: GilesPhillips

I posted an answer to your/the same question in www.theswamp.org

Norman Yuan

Drive CAD With Code

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report