Jump to content


Photo

using 'CAvax1.SetLayers' vb.net, can't find anything on the subject

setlayers

3 replies to this topic

#1 timpittser

timpittser

    Member

  • Members
  • PipPip
  • 29 posts

Posted 08 July 2014 - 08:51 PM

I want to be able to turn layers off and on within my code, in the old vb6 I got it to work.  But I'm having a hard time finding any info on the subject in vb.net, would appreciate some help, thanks.



#2 Athanasios Gardos

Athanasios Gardos

    Administrator

  • Admin
  • 359 posts
  • Gender:Male

Posted 09 July 2014 - 07:38 AM

It is working like in Avax Vector ActiveX:

Example set Layer #1 to hidden:

Dim sLayerNames() As String
Dim iLayersStatus() As Short
Dim lMax As Short

dim Index as Short
lMax = cAvax1.GetLayers(sLayerNames(), iLayerStatus())

Index=1 '(0 to 255)
iLayerStatus(Index) = iLayerStatus(Index) Or 1 '(Or 1 : Hidden/ Or 2 : Locked / Or 4 : NonPrintable)
Call cAvax1.SetLayers(sLayerNames(), iLayerStatus())


Athanasios Gardos
Avax-Software.com

#3 timpittser

timpittser

    Member

  • Members
  • PipPip
  • 29 posts

Posted 09 July 2014 - 12:49 PM

I tried this, and I'm getting an error, where the '()' is underlined and it states 'Number of indices is less than the number of dimensions of the indexed array'. 



#4 timpittser

timpittser

    Member

  • Members
  • PipPip
  • 29 posts

Posted 09 July 2014 - 07:09 PM

            Dim sLayerNames() As String, iLayerStatus() As Short, iMaxLayers As Short
            Dim lMax As Short
            Dim Index As Short
            Using conn = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & MDIParent1.TextBox2.Text & "\FieldSolutions.ixp;")
                Dim dbAdapter2 As New OleDb.OleDbDataAdapter("SELECT * from sketchlayers where layer_number = " & DataGridView1.CurrentRow.Cells(1).Value, conn)
                Dim dbDataSet2 As New DataSet
                Dim colstyle As New DataGridViewCellStyle
                dbAdapter2.Fill(dbDataSet2, "sketchlayers")
                Dim dbDataTable2 As DataTable = dbDataSet2.Tables(0)
                If dbDataTable2.Rows.Count > 0 Then
                    If dbDataTable2.Rows(0)("Layer_on_off") = "X" Then
                        Dim imgcell As New DataGridViewImageCell
                        DataGridView1.CurrentRow.Cells(2) = imgcell
                        DataGridView1.CurrentRow.Cells(2).Style.Alignment = DataGridViewContentAlignment.MiddleCenter
                        DataGridView1.CurrentRow.Cells(2).Value = (Image.FromFile(Application.StartupPath & "\off_light.bmp"))
                        dbDataTable2.Rows(0)("Layer_on_off") = ""
                        lMax = StakingCAD.CAvax1.GetLayers(sLayerNames, iLayerStatus)
                        Index = DataGridView1.CurrentRow.Cells(1).Value
                        iLayerStatus(Index) = 1 'iLayerStatus(Index) Or 1 '(Or 1 : Hidden/ Or 2 : Locked / Or 4 : NonPrintable)
                        Call StakingCAD.CAvax1.SetLayers(sLayerNames, iLayerStatus)
                    Else
                        Dim imgcell As New DataGridViewImageCell
                        DataGridView1.CurrentRow.Cells(2) = imgcell
                        DataGridView1.CurrentRow.Cells(2).Style.Alignment = DataGridViewContentAlignment.MiddleCenter
                        DataGridView1.CurrentRow.Cells(2).Value = (Image.FromFile(Application.StartupPath & "\on_light.bmp"))
                        dbDataTable2.Rows(0)("Layer_on_off") = "X"
                        lMax = StakingCAD.CAvax1.GetLayers(sLayerNames, iLayerStatus)
                        Index = DataGridView1.CurrentRow.Cells(1).Value
                        iLayerStatus(Index) = 0 'iLayerStatus(Index) Or 1 '(Or 1 : Hidden/ Or 2 : Locked / Or 4 : NonPrintable)
                        Call StakingCAD.CAvax1.SetLayers(sLayerNames, iLayerStatus)
                    End If
                End If
                Dim builder As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(dbAdapter2)
                dbAdapter2.Update(dbDataSet2, "sketchlayers")
            End Using
            DataGridView1.Refresh()

I finally got it to work, here's the code I used the switch layers on and off from a layer screen.





Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users