api-issue-tracker icon indicating copy to clipboard operation
api-issue-tracker copied to clipboard

Layout::Entity.locked= and Layout::Entity.locked? methods broken for Layout::Group Class

Open 3dmod opened this issue 9 months ago • 6 comments

Locked= and Locked? methods are broken for the Layout::Group Class

The following code will give the following results even though the entity is not locked when you open the file

Result

entity.locked?: false entity.locked?: true

Code

path="UPDATE TO LOCAL ENVIROMENT"
doc = Layout::Document.open(path)
ents = [
	Layout::FormattedText.new("Test1", Geom::Point2d.new(1, 1), Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT),
	Layout::FormattedText.new("Test2", Geom::Point2d.new(2, 1), Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT)]
to_add = Layout::Group.new(ents)
layer = doc.layers.first
page = doc.pages.first
doc.add_entity( to_add, layer, page )
entity = 
	case
	when layer.shared?
		doc.shared_entities.to_a.last
	else
		page.nonshared_entities.to_a.last
	end
puts "entity.locked?: #{entity.locked?}"
entity.locked = true
puts "entity.locked?: #{entity.locked?}"
doc.save( path )

macOS Sonoma 14.4.1 (23E224) SketchUp Version 24.0.483

3dmod avatar May 03 '24 16:05 3dmod

Logged as: SKEXT-4182

sketchup[bot] avatar May 06 '24 14:05 sketchup[bot]

Hello, I'm not sure I understand the issue. You are saying that initially upon creating a group that it shows that it is unlocked, then after you lock it it shows that it is locked? Is the issue that upon loading an existing file that the locked state of the group does not report correctly? Your code snippet makes a new group each time it is run so I am unsure of what you are looking for.

I also noticed this issue in your code layer = doc.pages.first should be layer = doc.layers.first.

ackarkka avatar May 06 '24 15:05 ackarkka

I want to take the following steps;

  1. create a group
  2. lock the group (Does not work)

So part one of the issue is that after I create the group and lock it does not lock.

So I set up a simplified script to troubleshoot with the following steps

  1. create a group
  2. test if group is locked. Result is correct.
  3. lock the group (Does not work)
  4. test if group is locked. Result is not correct. (Does not work)
  5. Open the saved layout file and notice that steps 3 and 4 are incorrect.

Thank you for pointing out the error in the code. It is correct in my local troubleshooting version and does not change the status of the issue.

3dmod avatar May 06 '24 16:05 3dmod

I want to take the following steps;

  1. create a group
  2. lock the group (Does not work)

In my testing, step 2. is working as expected. The group is locking and subsequently reporting as locked. Unlocking and reporting the locked state afterwards also works for me locally. I am not sure why we are not seeing the same results.

ackarkka avatar May 06 '24 17:05 ackarkka

Here is a screen recording with the exact code show above not working.

I even tried using a SU made template as a possible reason without any change in outcome.

I had to downsize to 720p to make it under the 10mb GitHub file size limit.

I can email it to you if you need high resolution.

https://github.com/SketchUp/api-issue-tracker/assets/76130464/a5f42167-2fdd-4b9f-a309-042dc0d096ef

3dmod avatar May 06 '24 19:05 3dmod

Thank you for the video. I was able to reproduce this through LayOut itself - Group entities are not serializing their locked status at all, and seemingly have not done so for a long time, if ever.

ackarkka avatar May 06 '24 22:05 ackarkka