Converter.Iterate

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
merco
Posts: 28
Joined: 25 May 2010, 10:03

Converter.Iterate

Post by merco » 23 Jun 2010, 17:50

I'm using

Code: Select all

 _cadParams = New CADIterate
        _cadParams.matrix = New CADMatrix
        _cadParams.matrix.data(0, 0) = 1
        _cadParams.matrix.data(1, 1) = 1
        _cadParams.matrix.data(2, 2) = 1
        _cadImage.Converter.AutoInsert = True

        _cadImage.Converter.Iterate(New CADEntityProc(AddressOf Me.ReadCADEntitiesParamsToPDF), Nothing, _cadParams)
To iterate over my entities...
in "ReadCADEntitiesParamsToPDF" i'm using

Code: Select all

 CADConst.DoScale2D((_cadParams))
        Dim layer As CADLayer = CADConst.EntLayer(entity, _cadParams.insert)
        If Not IsNothing(layer) AndAlso Not layer.Visible Then
            Exit Sub
        End If
to check if the layer is visible or not.

Before doing this i want to be able to hide some layer/blocks and recalculate new extensions without hidden objects...
But when i get here
Dim layer As CADLayer = CADConst.EntLayer(entity, _cadParams.insert)

My layer that should be hidden by "HideLayers" procedure is still visible.

What is wrong ? :?:

PS: also doing

Code: Select all

_cadImage.DrawMode = CADDrawMode.Black
 _cadImage.BackgroundColor = Color.White
doesn't affect to entities in iteration...

Code: Select all

 Public Sub HideLayers(ByVal LayerList As String)
             If LayerList <> "" Then
            Dim Elenco() As String = LayerList.Split(";"c)
            For Each Nome As String In Elenco
                If Nome.Trim <> "" Then
                    Dim Lay As CADLayer = _cadImage.Converter.LayerByName(Nome)
                    Lay.Visibility = False
                    Lay.Visible = False
                    Lay.Loaded(_cadImage.Converter)
                    _cadImage.Converter.Loads(Lay)

                End If
            Next
        End If
        _cadImage.GetExtents()
    End Sub

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Converter.Iterate

Post by support » 24 Jun 2010, 15:55

Hello.
Unfortunately the CADConverter.LayerByName method works correctly if only layer doesn't exists. Please modify your HideLayers method to access layers using index in _cadImage.Converter.Layers collection to get correct layer visibility settings.
Also the code

Code: Select all

_cadImage.DrawMode = CADDrawMode.Black
_cadImage.BackgroundColor = Color.White
works. The first code string set the black/white entities drawing mode. It will affect any entity that have some color, different from black or white. However if you want white background then please set BackColor property of the PictureBox object (like in White_Click method in demo app).

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

merco
Posts: 28
Joined: 25 May 2010, 10:03

Re: Converter.Iterate

Post by merco » 24 Jun 2010, 17:52

Ok i've changed my proc in

Code: Select all

 Public Sub HideLayers(ByVal LayerList As String)
        If LayerList <> "" Then
            Dim Elenco() As String = LayerList.Split(";"c)
            For Each Nome As String In Elenco
                If Nome.Trim <> "" Then
                    For Il As Integer = 0 To _cadImage.Converter.Layers.Count - 1
                        If _cadImage.Converter.Layers(Il).EntName.ToUpper = Nome.ToUpper Then
                            _cadImage.Converter.Layers(Il).Visibility = False
                            CType(_cadImage.Converter.Layers(Il), CADLayer).Visible = False
                            _cadImage.Converter.Layers(Il).Loaded(_cadImage.Converter)
                            _cadImage.Converter.Loads(_cadImage.Converter.Layers(Il))
                        End If
                    Next


                End If
            Next
        End If
        _cadImage.GetExtents()
    End Sub
But i'm missing some info.
I suppose that _cadImage.GetExtents() could get new drawing extensions, for entities that are still visible...
So if I hide some layers/ blocks is there a way/method to get new "visible" extensions ?

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Converter.Iterate

Post by support » 25 Jun 2010, 11:42

Hello.
CADImage.GetExtents() calculates extents using all entities regardless of each entity visibility. So, making some layer invisible do not make different. However you can create CADLayout object, add a set of required entities to it and set this layout as current (CADImage.CurrentLayout). The extents calculated for the current layout.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

merco
Posts: 28
Joined: 25 May 2010, 10:03

Re: Converter.Iterate

Post by merco » 25 Jun 2010, 14:16

... but i get the same extensions also with some layer hidden...

and the code to hide is ...

Code: Select all

_cadImage.Converter.Layers(Il).Visibility = False
                            CType(_cadImage.Converter.Layers(Il), CADLayer).Visible = False
                            _cadImage.Converter.Layers(Il).Loaded(_cadImage.Converter)
                            _cadImage.Converter.Loads(_cadImage.Converter.Layers(Il))

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Converter.Iterate

Post by support » 28 Jun 2010, 11:35

Hello.
Visibility of any layer only affects visibility of entities belonging to this layer. Please read my previous post. Create CADLayout object, add entities to this layout then set it as current and you will receive extents of the set of the entities that included to this layout by CADImage.GetExtents() method.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply