Help with Mac compatibility?
-
One of my plugins reports the attached error message, I presume upon loading:
Anyone know what kind of difference between a Mac, and PC might account for that error message. Within my code, I have variables like
vari=""
, and statements likehit_point != nil
. Could any of those be bad syntax, leading to problems on a Mac? -
Look for a String expression, in which the variable might not be yet defined (and therefor a nil object.)
-
Just a shot in the dark (and I'm probably completely wrong here), but should the variable be set at -0 or -1 to get it to work? I seem to remember something about Unity having a similar problem when writing javascript to open a door, ie you could get a door to rotate 180 degrees, but the variable needed to make it do so had to start at -1 rather than 0.
-
Looked at your plugin - you are using a line:
file_path_name=Sketchup.find_support_file "sketchup.exe", ""
One cause may be that since Mac's don't use .exe file extensions, the above line returns nil.
You can use this to find the plugins folder on either platform.
file_path_name = Sketchup.find_support_file("plugins")
-
Thanks for all the help everyone. Will help me code better. Jim, you hit the nail on the head. It's exactly what I have done. I'm flattered that you thought to look at my spaghetti coding. Just, when I thought that I was done with updating my code for this year. That line must be in half of the applications I've recently posted.
-
However, using the above does require that a plugin be installed in the Plugins folder. For maximum plugin portability, something similar to the following can be used to tell a plugin that its associated data folder is located relative to plugin file, rather than relative to THE Plugins folder.
my_dir = File.dirname(File.expand_path(__FILE__)) my_data_folder = File.join(my_dir, "my_data") my_small_image = File.join(my_data_folder, "my_small_image.png")
etc.
The incorrect assumption is that plugins are always installed in THE plugins folder, when in fact plugins can load from anywhere on a disk, network, or portable device.
I use a C:\Plugins folder that is used by all the versions of SketchUp I have installed. It's much easier not to have to copy and paste an entire folder of plugins from one version to the next.
There are a number of plugins that I can not move out of the Plugins folder because they were written under the assumption they would be put in SketchUp Plugins folder.
-
@jim said:
............
I use a C:\Plugins folder that is used by all the versions of SketchUp I have installed. It's much easier not to have to copy and paste an entire folder of plugins from one version to the next............Good idea, even though there are exceptions.
Advertisement