definitions.load_from_url failing when called from an HTMLDi

definitions.load_from_url failing when called from an HTMLDi

Postby gmolina1 » Thu Aug 09, 2018 3:28 am

Hello,

I am trying to load a ComponentDefinition from a local file in my PC (shipped with the extension, actually), but it just freezes when done from an HTMLDialog callback.

The original call is made from HERE, and it freezes when gets to THIS point.

However, when I call the GH::Groundhog::Photosensor.add(arguments) function from the Ruby console, it works beautifully.

Any idea why this might be happening? I could not find any other information online

THANKS TO ALL IN ADVANCE!

EDIT::: This is happening in Sketchup Make 2017, in macOS High Sierra.
0

gmolina1 
 

Re: definitions.load_from_url failing when called from an HT

Postby TIG » Thu Aug 09, 2018 6:19 pm

But ...load_from_url only works with proper URL HTTP address paths etc.
And, since you are already shipping the SKP within a subfolder with your extension, then you can simply use:
defn = Sketchup.active_model.definitions.load('full_path_to_subfolder/MODEL.skp')
You can easily get the path to your subfolder from __FILE__ as your file loads...
perhaps testing with:
unless model.definitions['MODEL'], to avoid reloading it ??
2
TIG
User avatar
TIG 
Global Moderator
 

Re: definitions.load_from_url failing when called from an HT

Postby gmolina1 » Thu Aug 09, 2018 9:11 pm

It worked wonderfully! I was using the load_from_url method with a file:// prefix before, and it also worked... but this makes more sense.

Thanks!
0

gmolina1 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 4 guests

Visit our sponsors: