Per this conversation, having a sketchup file name or any folder in the file path start with “u” causes Dynamic Components to stop functioning. Just lower case “u” evidently.
It is such a particular quirk, I would hope a bug fix could be put into place. A non-trivial problem for me, having my windows username start with “u” - so all my user folders and files are C:\Users\u…*
nope - this has been an issue for many years. make it a capital U and the problem goes away.
This is my Windows username starting with “u”, so I am unable to store SketchUp files in my documents, my desktop, or any folder associated with my account on the PC.
So the answer is that this codebase is so dead that a long running bug will not be fixed? Is it code available for me to update?
i recommend creating a support ticket with Trimble. meanwhile - Windows is generally not case sensitive so consider renaming your user name in the path with a capital U for now (fair straight forward), or change the plugins path (harder).
I added a link to this topic, to the existing bug report (SU-33345 in our system).
The underlying problem is SyntaxError: Invalid Unicode escape sequence when trying to eval() the string that contains the file name and path.
A possible fix is to edit the file dcbridge.js in the folder:
C:\Users\UserName\AppData\Roaming\SketchUp\SketchUp 20XX\SketchUp\Plugins\su_dynamiccomponents\js
Somewhere around line 2500 you’ll find the function:
su.getRubyData_ = function(queryid, key) {...};
Add the following line right before the eval() statement.
str = str.replace(/\\/g, '\\\\');
and let us know if this is a fix.
Edit: I’m trying to imagine what this change might break for other attributes stored in the Dynamic Component’s attribute hash and can’t hink of any. Perhaps Dan will think of something, he’s usually a master at this sort of question.
I tried that, and it didn’t solve the test case I was doing.
try {
var str = obj.replace(/\%22/gi, '"');
str = str.replace(/\n/gi, '\\n');
str = str.replace(/^\s(.*)\s$/, '$1');
str = str.replace(/\\/g, '\\\\');
obj = eval('(' + str + ')');
} catch (e) {
When I do this in Ruby, I replace the backslashes with forward slashes:
# replacement of backslashes in Ruby ...
str.gsub(/(\\\\|\\)/,'/')
In the above regular expression, it means replace either double or single backslash with a forward slash.
I myself have not ever tried to fix this exact bug in the DC code.
OK Colin, Something has been rewritten in your version of SU. Did you happen to see an error message in the Ruby console?
For comparison, here are the guts of that function from SU2023
try {
var str = obj.replace(/\%22/gi, '"');
str = str.replace(/\n/gi, '\\n');
str = str.replace(/\r/gi, '\\r');
str = str.replace(/^\s(.*)\s$/, '$1');
str = str.replace(/\/g, '\\');
str = str.replace(///g, '\/');
obj = eval('(' + str + ')');
} catch (e) {
BTW, the value in question, which is the path to the open Sketchup file, is used to locate any image files that might be associated with the Dynamic Component. That would be the ImageURL field.
Comments from the code
// If our root object contains a file variable then strip the
// filename off of its end to arrive at an absolute, local path to
// where we will look for CSS or image content.
. . .
// If the image path is just a filename (no folders) then append the
// local skp path to try for a local load.`
I had a typo in my File Explorer path, instead of going to /SketchUp/SketchUp 202x I went to /SketchUp/SketchUp 201x! At least I’ve fixed that much older version of SketchUp.
After editing the right dcbridge.js, your fix worked. I didn’t try Dan’s version.
I expect that Dan’s approach is more to the point; seeing that in configurator.js the code does just that conversion!
// If our root object contains a file variable then strip the
// filename off of its end to arrive at an absolute, local path to
// where we will look for CSS or image content.
if (su.isValid(root.file)) {
filePath = su.unescapeHTML(root.file + '');
filePath = filePath.replace(/\\/gi, '/');
localPath = filePath.substring(0, filePath.lastIndexOf('/') + 1);
} else {
localPath = '';
}
I snorted my coffee right there.
At one pont I had several versions of the file open, from SU8 through…, and found myself to be quite lost a few times.
I’ve done a little snooping into the internals of the dynamic components code and have come up with a solution(?) that yo can just drop intpo the Sketchup Plugins diretory.
Download this fle and place it in your plugins directory. Restart Sketchup. The files name starts with ZZ- so that it will be loadedx after the rest of the Dynamic Compnent extension.
ZZ-entity_to_json_patch.rb (324 Bytes)
Also for those with prying eyes, here’s the snooping information.
entity to json snooping.txt (5.8 KB)
I made the following edit in dcbridge.js / .getRubyData_ as suggested.
// Workaround for dynamiccomponents bug SU-33345
// str = str.replace(/\/g, '\\');
str = str.replace(/\/g, '\/');
I was able to install the zz extension you created, and saw what it was doing - but for whatever reason it didn’t resolve the issue.
I took your Ruby patch approach and went right to the source above of changing the modification of char 92. Worked like a charm (unless it is the source of weird behavior of DC components moving in space when I resize them, but I’m hoping that’s a different adventure).
I appreciate all the work and insight (as well as everyone else); this is a great community.
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.