Move to layer

Hi,
I need help regarding move to layer I have some notes, curves, Tablenote, symbols in my sheet A0. now when I am changing the sheet from A0 to A1 the total object array value is Geeting change and I ma Geeting error with another size.
How I can control the object count with different sheet sizes.
' ----------------------------------------------
' Menu: Format->Move to Layer...
' ----------------------------------------------
Dim markId14 As NXOpen.Session.UndoMarkId = Nothing
markId14 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Move Layer")

Dim objectArray1(201) As NXOpen.DisplayableObject
Dim note1 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 80 1"), NXOpen.Annotations.Note)

objectArray1(0) = note1
Dim note2 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 1 1"), NXOpen.Annotations.Note)

objectArray1(1) = note2
Dim note3 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 76 1"), NXOpen.Annotations.Note)

objectArray1(2) = note3
Dim note4 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 74 1"), NXOpen.Annotations.Note)

objectArray1(3) = note4
Dim note5 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 70 1"), NXOpen.Annotations.Note)

objectArray1(4) = note5
Dim line1 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 10 1"), NXOpen.Line)

objectArray1(5) = line1
Dim line2 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 3 1"), NXOpen.Line)

objectArray1(6) = line2
Dim line3 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 86 1"), NXOpen.Line)

objectArray1(7) = line3
Dim line4 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 71 1"), NXOpen.Line)

objectArray1(8) = line4
Dim line5 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 65 1"), NXOpen.Line)

objectArray1(9) = line5
Dim line6 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 62 1"), NXOpen.Line)

objectArray1(10) = line6
Dim line7 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 55 1"), NXOpen.Line)

objectArray1(11) = line7
Dim line8 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 48 1"), NXOpen.Line)

objectArray1(12) = line8
Dim line9 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 41 1"), NXOpen.Line)

objectArray1(13) = line9
Dim line10 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 34 1"), NXOpen.Line)

objectArray1(14) = line10
Dim line11 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 27 1"), NXOpen.Line)

objectArray1(15) = line11
Dim note6 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 10 1"), NXOpen.Annotations.Note)

objectArray1(16) = note6
Dim line12 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 111 1"), NXOpen.Line)

objectArray1(17) = line12
Dim line13 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 112 1"), NXOpen.Line)

objectArray1(18) = line13
Dim note7 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 44 1"), NXOpen.Annotations.Note)

objectArray1(19) = note7
Dim note8 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 25 1"), NXOpen.Annotations.Note)

objectArray1(20) = note8
Dim line14 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 32 1"), NXOpen.Line)

objectArray1(21) = line14
Dim note9 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 35 1"), NXOpen.Annotations.Note)

objectArray1(22) = note9
Dim line15 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 115 1"), NXOpen.Line)

objectArray1(23) = line15
Dim note10 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 66 1"), NXOpen.Annotations.Note)

objectArray1(24) = note10
Dim line16 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 101 1"), NXOpen.Line)

objectArray1(25) = line16
Dim line17 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 94 1"), NXOpen.Line)

objectArray1(26) = line17
Dim line18 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 88 1"), NXOpen.Line)

objectArray1(27) = line18
Dim line19 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 81 1"), NXOpen.Line)

objectArray1(28) = line19
Dim note11 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 56 1"), NXOpen.Annotations.Note)

objectArray1(29) = note11
Dim note12 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 73 1"), NXOpen.Annotations.Note)

objectArray1(30) = note12
Dim line20 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 21 1"), NXOpen.Line)

objectArray1(31) = line20
Dim line21 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 14 1"), NXOpen.Line)

objectArray1(32) = line21
Dim note13 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 67 1"), NXOpen.Annotations.Note)

objectArray1(33) = note13
Dim note14 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 18 1"), NXOpen.Annotations.Note)

objectArray1(34) = note14
Dim line22 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 75 1"), NXOpen.Line)

objectArray1(35) = line22
Dim line23 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 69 1"), NXOpen.Line)

objectArray1(36) = line23
Dim line24 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 59 1"), NXOpen.Line)

objectArray1(37) = line24
Dim line25 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 52 1"), NXOpen.Line)

objectArray1(38) = line25
Dim note15 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 13 1"), NXOpen.Annotations.Note)

objectArray1(39) = note15
Dim line26 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 38 1"), NXOpen.Line)

objectArray1(40) = line26
Dim line27 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 31 1"), NXOpen.Line)

objectArray1(41) = line27
Dim line28 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 8 1"), NXOpen.Line)

objectArray1(42) = line28
Dim note16 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 49 1"), NXOpen.Annotations.Note)

objectArray1(43) = note16
Dim line29 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 106 1"), NXOpen.Line)

objectArray1(44) = line29
Dim note17 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 45 1"), NXOpen.Annotations.Note)

objectArray1(45) = note17
Dim note18 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 43 1"), NXOpen.Annotations.Note)

objectArray1(46) = note18
Dim note19 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 41 1"), NXOpen.Annotations.Note)

objectArray1(47) = note19
Dim note20 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 33 1"), NXOpen.Annotations.Note)

objectArray1(48) = note20
Dim note21 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 58 1"), NXOpen.Annotations.Note)

objectArray1(49) = note21
Dim note22 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 64 1"), NXOpen.Annotations.Note)

objectArray1(50) = note22
Dim line30 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 105 1"), NXOpen.Line)

objectArray1(51) = line30
Dim line31 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 98 1"), NXOpen.Line)

objectArray1(52) = line31
Dim line32 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 91 1"), NXOpen.Line)

objectArray1(53) = line32
Dim note23 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 34 1"), NXOpen.Annotations.Note)

objectArray1(54) = note23
Dim line33 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 78 1"), NXOpen.Line)

objectArray1(55) = line33
Dim hatch1 As NXOpen.Annotations.Hatch = CType(workPart.FindObject("ENTITY 25 83 1"), NXOpen.Annotations.Hatch)

objectArray1(56) = hatch1
Dim note24 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 55 1"), NXOpen.Annotations.Note)

objectArray1(57) = note24
Dim note25 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 72 1"), NXOpen.Annotations.Note)

objectArray1(58) = note25
Dim hatch2 As NXOpen.Annotations.Hatch = CType(workPart.FindObject("ENTITY 25 82 1"), NXOpen.Annotations.Hatch)

objectArray1(59) = hatch2
Dim note26 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 16 1"), NXOpen.Annotations.Note)

objectArray1(60) = note26
Dim line34 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 4 1"), NXOpen.Line)

objectArray1(61) = line34
Dim hatch3 As NXOpen.Annotations.Hatch = CType(workPart.FindObject("ENTITY 25 81 1"), NXOpen.Annotations.Hatch)

objectArray1(62) = hatch3
Dim line35 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 72 1"), NXOpen.Line)

objectArray1(63) = line35
Dim line36 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 66 1"), NXOpen.Line)

objectArray1(64) = line36
Dim line37 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 18 1"), NXOpen.Line)

objectArray1(65) = line37
Dim line38 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 56 1"), NXOpen.Line)

objectArray1(66) = line38
Dim line39 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 49 1"), NXOpen.Line)

objectArray1(67) = line39
Dim line40 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 42 1"), NXOpen.Line)

objectArray1(68) = line40
Dim line41 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 35 1"), NXOpen.Line)

objectArray1(69) = line41
Dim line42 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 28 1"), NXOpen.Line)

objectArray1(70) = line42
Dim note27 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 8 1"), NXOpen.Annotations.Note)

objectArray1(71) = note27
Dim note28 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 7 1"), NXOpen.Annotations.Note)

objectArray1(72) = note28
Dim note29 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 42 1"), NXOpen.Annotations.Note)

objectArray1(73) = note29
Dim note30 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 40 1"), NXOpen.Annotations.Note)

objectArray1(74) = note30
Dim note31 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 11 1"), NXOpen.Annotations.Note)

objectArray1(75) = note31
Dim note32 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 69 1"), NXOpen.Annotations.Note)

objectArray1(76) = note32
Dim note33 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 62 1"), NXOpen.Annotations.Note)

objectArray1(77) = note33
Dim line43 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 7 1"), NXOpen.Line)

objectArray1(78) = line43
Dim note34 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 75 1"), NXOpen.Annotations.Note)

objectArray1(79) = note34
Dim line44 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 95 1"), NXOpen.Line)

objectArray1(80) = line44
Dim note35 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 32 1"), NXOpen.Annotations.Note)

objectArray1(81) = note35
Dim line45 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 82 1"), NXOpen.Line)

objectArray1(82) = line45
Dim hatch4 As NXOpen.Annotations.Hatch = CType(workPart.FindObject("ENTITY 25 84 1"), NXOpen.Annotations.Hatch)

objectArray1(83) = hatch4
Dim line46 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 107 1"), NXOpen.Line)

objectArray1(84) = line46
Dim note36 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 31 1"), NXOpen.Annotations.Note)

objectArray1(85) = note36
Dim note37 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 15 1"), NXOpen.Annotations.Note)

objectArray1(86) = note37
Dim note38 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 52 1"), NXOpen.Annotations.Note)

objectArray1(87) = note38
Dim note39 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 24 1"), NXOpen.Annotations.Note)

objectArray1(88) = note39
Dim line47 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 15 1"), NXOpen.Line)

objectArray1(89) = line47
Dim note40 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 20 1"), NXOpen.Annotations.Note)

objectArray1(90) = note40
Dim note41 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 65 1"), NXOpen.Annotations.Note)

objectArray1(91) = note41
Dim line48 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 76 1"), NXOpen.Line)

objectArray1(92) = line48
Dim line49 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 70 1"), NXOpen.Line)

objectArray1(93) = line49
Dim line50 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 63 1"), NXOpen.Line)

objectArray1(94) = line50
Dim line51 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 60 1"), NXOpen.Line)

objectArray1(95) = line51
Dim line52 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 53 1"), NXOpen.Line)

objectArray1(96) = line52
Dim line53 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 46 1"), NXOpen.Line)

objectArray1(97) = line53
Dim line54 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 39 1"), NXOpen.Line)

objectArray1(98) = line54
Dim line55 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 104 1"), NXOpen.Line)

objectArray1(99) = line55
Dim note42 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 14 1"), NXOpen.Annotations.Note)

objectArray1(100) = note42
Dim note43 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 19 1"), NXOpen.Annotations.Note)

objectArray1(101) = note43
Dim note44 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 47 1"), NXOpen.Annotations.Note)

objectArray1(102) = note44
Dim note45 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 23 1"), NXOpen.Annotations.Note)

objectArray1(103) = note45
Dim note46 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 26 1"), NXOpen.Annotations.Note)

objectArray1(104) = note46
Dim note47 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 39 1"), NXOpen.Annotations.Note)

objectArray1(105) = note47
Dim note48 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 9 1"), NXOpen.Annotations.Note)

objectArray1(106) = note48
Dim note49 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 27 1"), NXOpen.Annotations.Note)

objectArray1(107) = note49
Dim line56 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 85 1"), NXOpen.Line)

objectArray1(108) = line56
Dim line57 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 1 1"), NXOpen.Line)

objectArray1(109) = line57
Dim line58 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 22 1"), NXOpen.Line)

objectArray1(110) = line58
Dim line59 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 99 1"), NXOpen.Line)

objectArray1(111) = line59
Dim line60 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 92 1"), NXOpen.Line)

objectArray1(112) = line60
Dim note50 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 79 1"), NXOpen.Annotations.Note)

objectArray1(113) = note50
Dim line61 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 79 1"), NXOpen.Line)

objectArray1(114) = line61
Dim line62 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 68 1"), NXOpen.Line)

objectArray1(115) = line62
Dim note51 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 30 1"), NXOpen.Annotations.Note)

objectArray1(116) = note51
Dim line63 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 108 1"), NXOpen.Line)

objectArray1(117) = line63
Dim line64 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 19 1"), NXOpen.Line)

objectArray1(118) = line64
Dim line65 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 12 1"), NXOpen.Line)

objectArray1(119) = line65
Dim line66 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 5 1"), NXOpen.Line)

objectArray1(120) = line66
Dim note52 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 60 1"), NXOpen.Annotations.Note)

objectArray1(121) = note52
Dim line67 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 73 1"), NXOpen.Line)

objectArray1(122) = line67
Dim line68 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 67 1"), NXOpen.Line)

objectArray1(123) = line68
Dim note53 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 21 1"), NXOpen.Annotations.Note)

objectArray1(124) = note53
Dim note54 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 48 1"), NXOpen.Annotations.Note)

objectArray1(125) = note54
Dim line69 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 57 1"), NXOpen.Line)

objectArray1(126) = line69
Dim line70 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 50 1"), NXOpen.Line)

objectArray1(127) = line70
Dim line71 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 43 1"), NXOpen.Line)

objectArray1(128) = line71
Dim line72 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 36 1"), NXOpen.Line)

objectArray1(129) = line72
Dim line73 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 29 1"), NXOpen.Line)

objectArray1(130) = line73
Dim note55 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 53 1"), NXOpen.Annotations.Note)

objectArray1(131) = note55
Dim line74 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 102 1"), NXOpen.Line)

objectArray1(132) = line74
Dim note56 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 46 1"), NXOpen.Annotations.Note)

objectArray1(133) = note56
Dim line75 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 109 1"), NXOpen.Line)

objectArray1(134) = line75
Dim line76 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 25 1"), NXOpen.Line)

objectArray1(135) = line76
Dim note57 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 38 1"), NXOpen.Annotations.Note)

objectArray1(136) = note57
Dim line77 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 24 1"), NXOpen.Line)

objectArray1(137) = line77
Dim note58 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 50 1"), NXOpen.Annotations.Note)

objectArray1(138) = note58
Dim line78 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 110 1"), NXOpen.Line)

objectArray1(139) = line78
Dim line79 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 103 1"), NXOpen.Line)

objectArray1(140) = line79
Dim line80 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 96 1"), NXOpen.Line)

objectArray1(141) = line80
Dim line81 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 89 1"), NXOpen.Line)

objectArray1(142) = line81
Dim line82 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 83 1"), NXOpen.Line)

objectArray1(143) = line82
Dim line83 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 23 1"), NXOpen.Line)

objectArray1(144) = line83
Dim note59 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 78 1"), NXOpen.Annotations.Note)

objectArray1(145) = note59
Dim note60 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 29 1"), NXOpen.Annotations.Note)

objectArray1(146) = note60
Dim line84 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 16 1"), NXOpen.Line)

objectArray1(147) = line84
Dim line85 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 9 1"), NXOpen.Line)

objectArray1(148) = line85
Dim line86 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 2 1"), NXOpen.Line)

objectArray1(149) = line86
Dim note61 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 59 1"), NXOpen.Annotations.Note)

objectArray1(150) = note61
Dim note62 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 68 1"), NXOpen.Annotations.Note)

objectArray1(151) = note62
Dim line87 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 64 1"), NXOpen.Line)

objectArray1(152) = line87
Dim line88 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 61 1"), NXOpen.Line)

objectArray1(153) = line88
Dim line89 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 54 1"), NXOpen.Line)

objectArray1(154) = line89
Dim line90 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 47 1"), NXOpen.Line)

objectArray1(155) = line90
Dim line91 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 40 1"), NXOpen.Line)

objectArray1(156) = line91
Dim line92 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 33 1"), NXOpen.Line)

objectArray1(157) = line92
Dim line93 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 26 1"), NXOpen.Line)

objectArray1(158) = line93
Dim note63 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 12 1"), NXOpen.Annotations.Note)

objectArray1(159) = note63
Dim note64 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 6 1"), NXOpen.Annotations.Note)

objectArray1(160) = note64
Dim note65 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 4 1"), NXOpen.Annotations.Note)

objectArray1(161) = note65
Dim note66 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 2 1"), NXOpen.Annotations.Note)

objectArray1(162) = note66
Dim note67 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 37 1"), NXOpen.Annotations.Note)

objectArray1(163) = note67
Dim note68 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 57 1"), NXOpen.Annotations.Note)

objectArray1(164) = note68
Dim line94 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 114 1"), NXOpen.Line)

objectArray1(165) = line94
Dim note69 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 63 1"), NXOpen.Annotations.Note)

objectArray1(166) = note69
Dim tableSection1 As NXOpen.Annotations.TableSection = CType(workPart.Annotations.TableSections.FindObject("ENTITY 165 2 1"), NXOpen.Annotations.TableSection)

objectArray1(167) = tableSection1
Dim line95 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 93 1"), NXOpen.Line)

objectArray1(168) = line95
Dim line96 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 87 1"), NXOpen.Line)

objectArray1(169) = line96
Dim line97 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 80 1"), NXOpen.Line)

objectArray1(170) = line97
Dim line98 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 45 1"), NXOpen.Line)

objectArray1(171) = line98
Dim note70 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 77 1"), NXOpen.Annotations.Note)

objectArray1(172) = note70
Dim note71 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 28 1"), NXOpen.Annotations.Note)

objectArray1(173) = note71
Dim note72 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 17 1"), NXOpen.Annotations.Note)

objectArray1(174) = note72
Dim line99 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 20 1"), NXOpen.Line)

objectArray1(175) = line99
Dim line100 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 13 1"), NXOpen.Line)

objectArray1(176) = line100
Dim line101 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 6 1"), NXOpen.Line)

objectArray1(177) = line101
Dim tableSection2 As NXOpen.Annotations.TableSection = CType(workPart.Annotations.TableSections.FindObject("ENTITY 165 15 1"), NXOpen.Annotations.TableSection)

objectArray1(178) = tableSection2
Dim line102 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 74 1"), NXOpen.Line)

objectArray1(179) = line102
Dim line103 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 100 1"), NXOpen.Line)

objectArray1(180) = line103
Dim note73 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 54 1"), NXOpen.Annotations.Note)

objectArray1(181) = note73
Dim note74 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 22 1"), NXOpen.Annotations.Note)

objectArray1(182) = note74
Dim line104 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 58 1"), NXOpen.Line)

objectArray1(183) = line104
Dim line105 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 51 1"), NXOpen.Line)

objectArray1(184) = line105
Dim line106 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 44 1"), NXOpen.Line)

objectArray1(185) = line106
Dim line107 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 37 1"), NXOpen.Line)

objectArray1(186) = line107
Dim line108 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 30 1"), NXOpen.Line)

objectArray1(187) = line108
Dim note75 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 51 1"), NXOpen.Annotations.Note)

objectArray1(188) = note75
Dim line109 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 113 1"), NXOpen.Line)

objectArray1(189) = line109
Dim note76 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 5 1"), NXOpen.Annotations.Note)

objectArray1(190) = note76
Dim note77 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 3 1"), NXOpen.Annotations.Note)

objectArray1(191) = note77
Dim note78 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 71 1"), NXOpen.Annotations.Note)

objectArray1(192) = note78
Dim line110 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 116 1"), NXOpen.Line)

objectArray1(193) = line110
Dim note79 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 36 1"), NXOpen.Annotations.Note)

objectArray1(194) = note79
Dim line111 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 11 1"), NXOpen.Line)

objectArray1(195) = line111
Dim note80 As NXOpen.Annotations.Note = CType(workPart.FindObject("ENTITY 25 61 1"), NXOpen.Annotations.Note)

objectArray1(196) = note80
Dim line112 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 17 1"), NXOpen.Line)

objectArray1(197) = line112
Dim line113 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 97 1"), NXOpen.Line)

objectArray1(198) = line113
Dim line114 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 90 1"), NXOpen.Line)

objectArray1(199) = line114
Dim line115 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 84 1"), NXOpen.Line)

objectArray1(200) = line115
Dim line116 As NXOpen.Line = CType(workPart.Lines.FindObject("ENTITY 3 77 1"), NXOpen.Line)

objectArray1(201) = line116
workPart.Layers.MoveDisplayableObjects(256, objectArray1)

I'm assuming that the code you posted is from a recorded journal. Recorded journals will record each specific object that was used in that journal. If you want to get all the objects on a specific layer, there are better ways of doing it. For example, the .GetAllObjectsOnLayer() method will give you all the objects on a specified layer.

Hi,
I don't have any experience of .VB I am totally new can you please share the example. requirement is to get border and zones, table to get in layer 256

That code would look something like this:

Const fromLayer As Integer = 250
Const toLayer As Integer = 256

theSession.Parts.Work.Layers.MoveDisplayableObjects(toLayer, theSession.Parts.Work.Layers.GetAllObjectsOnLayer(fromLayer))

This will find all the objects on layer 250 and move them to layer 256.