(solved)locked files
-
Hi.
This is probably trivial and basic, but I gotta ask. It's driving me totally nuts.
I've created some components and saved them. Now it appears a locked icon next to the file name in the browser And I then cannot retrieve them with ruby..
I wanted first to save a component with textures and thought that was the issue, but with or without materials the problem remains.And no, it is not locked in Sketchup when saving. Tried different things. Right click save as, saving from the component broswer, saving in different folders, etc..
Funny thing, did exact same thing a month ago and fine. Haven't changed any security setting or something like that..
-
Is the component filename different then the model filename that Sketchup has open ??
The "locked" file icon would indicate that the file was currently in use by some application.
What happens when you close Sketchup ?? Does the icon return to normal ??
-
Yes. Different file name. And no change in icons when I close Sketchup.
I acctually did a reboot to doublecheck. Still persists.@unknownuser said:
The "locked" file icon would indicate that the file was currently in use by some application
That could be helpful.
Although my first intuition was that I somehow was creating components in a different(or wrong) manner than before. Or some strange pop in my settings.
I can save a SKP file in the file browser "Save as". And that come through as a normal skp icon.
Very strange indeed.
Thanks for the help Dan. Will investigate further tomorrow. It's late..
-
WHERE are you saving these "locked" files ??
IF you are saving files in the "Program Files" path, or other places that Windows feels is unsafe, then the system will lock the files as a security feature of Win7.
You should save them under the User Documents path (because the user will always have read and write permissions on the directories beneath their "user" profile.)
compname = 'widget' # or whatever, prompt the user, etc. if RUBY_PLATFORM =~ /darwin/ # Mac userpath = ENV['HOME'] docsdir = 'Documents' else # Windows # File.expand_path() will convert '\'s to '/'s userpath = File.expand_path( ENV['USERPROFILE'] ) ver = %x[ver].strip!.chop!.split().last.to_f docsdir =( ver<6.0 ? 'My Documents' ; 'Documents' ) end docspath = File.join( userpath, docsdir ) Dir.mkdir( docspath ) unless Kernel.test( ?d, docspath ) filepath = docspath.dup # make a copy ['Google Sketchup','Sketchup 8','Components'].each {|subdir| filepath = File.join( filepath, subdir ) Dir.mkdir( filepath ) unless Kernel.test( ?d, filepath ) } savepath = File.join( filepath, "#{compname}.skp" ) success = my_definition.save_as( savepath )
NOTE: On non-English Windows the name of the "Documents" dir may be in the local language.
-
Hi Dan, and thanks.
Yes it appears to be Win 7 security issue as you say. Wierd..
I was saving the files in Sketchup/Components.
If I wasen't clear about what I was doing, In this case I was talking about saving the components manually, not by code. (Building a library for Hatchfaces).
But thanks for the code. I'll think I'll need something like that further on, so you did not type it for nothing.Anyway, I saved the components in "User Documents path". Then moved them to desired folder.
That did work. I can live with that..
Just wonder if there will be any similar issues providing a plugin with a folder of premade skp files. -
No, still don't work as expected. Probaly some win7 issue. But whats tripping me up is that it is happening all of a sudden.
Now the skp files look OK in the browser. Same rights and fileattributes etc. But the new files don't show up when I create a list of names for a webdialog. Rebooting doesent help.
To explain further I have a folder (something like: Plugins\JOLtest\Std_comps) where there are specific Hatch components.
Last month or so I put some components there for testing, and their name show up in the dialog just fine. Yesterday I tried to add a few more and this happend(read topic).I'm using this simple Ruby code to get the components name to string array. For using it in Dialog. It works ok, since this folder will only contain specific Hatchcomps.
def getComps(folder)#sorts .skp files to strings to array comps=[] path = File.expand_path( File.dirname(__FILE__) ) path = File.join( path, folder ) #gets foldername from methodcall. std_list=Dir.entries(path) std_list.to_a.each{|fil| #return list as string if str. has ".skp" in it. if fil.include? ".skp" comps << fil.chomp(".skp") #remove ".skp" extension name end } compList=comps.sort.join('|') #join each listitem with "|". return compList end
And then in a callback do an execute script like:
@my_dialog.execute_script(%(document.getElementById("std_list").value="#{getComps('JOLtest\Std_comps')}";))
Although I don't think the code is relevant to this problem, I'm just showing it so it's clear whats going on.
Edited: BTW I can drag the "Nonworking" components into Sketchup(from folder), so they are not corrupted in that kind of way.
-
OOPs
There was a typo in my code. Now the comps are loading(hopefully).
Forget the last post.Edit: Problem solved by saving components(like Dan said) in user/my documents/anyfolder.
Then I can copy and paste from there.
Advertisement