Sketchup.active_model.layers returns <Deleted Entity>?
-
I'm not sure how I did it, but calling:
Sketchup.active_model.layers #<Deleted Entity;0xb016af8>I go to the Layers dialog, add some new layers - same thing. File > New == same thing.
How in the world can the layers object become deleted, and can I do anything about it from ruby? Shouldn't it at least always contain Layer0, since it is always present?
Thanks.
-
what ever that sound is when you run your fingers up and down over your lips?
blblblbblblblb....
cuz I ain't got no clue whatcha talkin bout george....
-
You can get the same thing with Sketchup.active_model.pages
The problem usually occurs when something is assigned to a variable (ie pages=Sketchup.active_model.pages), the script is loaded (say, on SU startup), and then you start/open a new model. pages was defined with the original model, and doesn't get redefined to the new model.I've mentioned this to the SU crew regarding pages. I can add that you've had the same problem with layers
-
On a related issue, it doesn't look like a layer's page_behavior is saved with the model.
Sketchup.send_action("showRubyPanel;") UI.menu.add_item("Layers y Pages") { layer = Sketchup.active_model.layers.add Sketchup.active_model.layers.unique_name layer.page_behavior = (LAYER_HIDDEN_BY_DEFAULT|LAYER_IS_HIDDEN_ON_NEW_PAGES) #layer.page_behavior = LAYER_IS_HIDDEN_ON_NEW_PAGES #layer.page_behavior = LAYER_HIDDEN_BY_DEFAULT page = Sketchup.active_model.pages.add } UI.menu.add_item("layer behavior") { puts "=" * 25 Sketchup.active_model.layers.each { |layer| puts layer.page_behavior } }@rickw said:
You can get the same thing with Sketchup.active_model.pages
The problem usually occurs when something is assigned to a variable (ie pages=Sketchup.active_model.pages), the script is loaded (say, on SU startup), and then you start/open a new model. pages was defined with the original model, and doesn't get redefined to the new model.I've mentioned this to the SU crew regarding pages. I can add that you've had the same problem with layers.
-
Just tried this with FlightPath (which uses LAYER_IS_HIDDEN_ON_NEW_PAGES) and it worked fine. I saved the model, started a new model, then re-opened the saved model and checked the layer.page_behavior. Everything was saved with the model.
-
@rickw said:
Just tried this with FlightPath (which uses LAYER_IS_HIDDEN_ON_NEW_PAGES) and it worked fine. I saved the model, started a new model, then re-opened the saved model and checked the layer.page_behavior. Everything was saved with the model.
It doesn't work for my posted example. Did I do something wrong?
-
I tried your example script, and see the problem you see.
According to the SU ruby docs:
"Currently there are two behaviors defined.
A page keeps a list of layers that do not have their default behavior. If a layer is not in that list, then it is set to its default visibility determined by one of these flags.
LAYER_VISIBLE_BY_DEFAULT 0x0000
LAYER_HIDDEN_BY_DEFAULT 0x0001"The strange thing is that in commenting out different lines and trying the script again, LAYER_IS_HIDDEN_ON_NEW_PAGES is the setting that sticks - not LAYER_IS_HIDDEN_BY_DEFAULT.
I'll report that to the SU crew.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better đź’—
Register LoginAdvertisement