It’s very difficult, to tell what’s wrong without seeing your code.
Maybe you didn’t use the #save method correctly, or maybe you didn’t change anything, or changed incorrectly, before saving.
Perhaps, the document was open in Layout while being edited from Ruby.
Ok working on answering that properly in the meantime do you know how to delete the leader for label or render it invisible without colour matching the background Via the API?
I have the path arg working and the version has worked at least once on one approach .
The problem could have been open files so am just checking .
b. Your hardware info in your forum profile looks to be out of date.
c. LayOut documents are weird in that many stylish features must be accessed via substyle.
# Where label is a reference to your label object:
style = label.style
substyle = style.get_sub_style(Layout::Style::LABEL_LEADER_LINE)
substyle.stroked = false
substyle.start_arrow_type = Layout::Style::ARROW_NONE
# Set the style to apply changes
style.set_sub_style(Layout::Style::LABEL_LEADER_LINE, substyle)
label.style = style
So, basically if it does not work assigning to the entity.style, then try assigning to it’s substyle.
I’m influenced by ChatGPT towards interpreting my experience that I’ve only been able to save copies of the file as it was opened rather than amended.
Here’s the code pattern I’m using :
‘path = #filepath and filename as per Ruby Documentation
vers = Layout::Document::VERSION_CURRENT
doc = Layout::Document.open(path)
#make modifications
status = doc.save(path,vers)
doc = doc.save(path,vers)’
Basic context would be iterating labels and renumbering their plain text.
It is not likely that you would need to call save twice.
Do you code defensively?
Ie, check that the result of calling getter methods is valid before proceeding.
Do you check the status of the save call?
Have you checked the modtime for the file afterward to see if it was changed?
The first post said you needed to change the styling of the leader for some labels.
NOTE: I edited the previous snippet I posted. Had a brain-fart, meant “label” when I kept writing “leader”.
Yeah well, I’m giving the whole thing a bit of a work over. Looking to see whether I can create some workflows that beat manual editing.
The catalyst and most significant problem is I can’t get my saving code to work .
It works every time It’s the same file I opened if I use a new file name.
But in many of the tests it could’ve been that the amendment code was failing. For example, some of the nested iterations were forcing an exit .
I threw in the Leader question because that’s a little bit further down the track and I saw Mr. Sage lurking and thought I might get a bit of a hand.
I did see the Status methods but I had just been monitoring the time in the windows environment after a refresh.
Oh! Perhaps you did not notice that there are several overrides of the Layout::Document.save method ?
Ie, the simplest override has no arguments and is used to save the current file (as modified) to the same path is was opened from, at the current version.
The next simplest, override (i.e., way of using a method,) is to pass an empty path string, rather than passing the current file’s path, which can save the file (as modified) but perhaps with a different version constant for the 2nd argument.
The 3rd way (what you have been showing in your snippets) is for saving to a different path or filename.