Skip to content

Commit

Permalink
add Index prop for Layer cite #655
Browse files Browse the repository at this point in the history
  • Loading branch information
fraguada committed Nov 21, 2024
1 parent d286c4c commit 9589bd4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/bindings/bnd_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ void initLayerBindings(void*)
.function("setPersistentLocking", &BND_Layer::SetPersistentLocking)
.function("unsetPersistentLocking", &BND_Layer::UnsetPersistentLocking)
.property("expanded", &BND_Layer::IsExpanded, &BND_Layer::SetExpanded)
.property("index", &BND_Layer::GetIndex)
;
}
#endif
24 changes: 24 additions & 0 deletions tests/javascript/file3dm.LayerTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,28 @@ test('DeleteLayer', async () => {

expect(qtyLayers === 2 && qtyLayers2 === 1).toBe(true)

})

test('LayerIndex', async () => {

const file3dm = new rhino.File3dm()
file3dm.applicationName = 'rhino3dm.js'
file3dm.applicationDetails = 'rhino3dm-tests-layerTable-layerIndex'
file3dm.applicationUrl = 'https://rhino3d.com'

//create layers
const layer1 = new rhino.Layer()
layer1.Name = 'layer1'
layer1.Color = { r: 255, g: 0, b: 255, a: 255 }

const layer2 = new rhino.Layer()
layer2.Name = 'layer2'

const index1 = file3dm.layers().add(layer1)
file3dm.layers().add(layer2)

const _index1 = file3dm.layers().findIndex(index1).index

expect(index1 === _index1).toBe(true)

})

0 comments on commit 9589bd4

Please sign in to comment.