Load Sketchup file from URL or Specific Diretory
-
Hi,
I am implementing a ruby code that loads me a sketchup file(skp), this is my code:
point = Geom::Point3d.new 10,20,30
transform = Geom::Transformation.new point
model = Sketchup.active_model
entities = model.active_entities
path = Sketchup.find_support_file "chimney.skp",
"C:/Users/usuario/Downloads/pluginsketchUp/Sketchup/org.dworks.suide_1.0.0/exe/"
definitions = model.definitions
componentdefinition = definitions.load path
instance = entities.add_instance componentdefinition, transform
if (instance)
UI.messagebox instance
else
UI.messagebox "Failure"
endHow could I do, the file loads of a different path to "Components/Components Sampler/" or maybe of a specific url?.
Thanks in advance.
-
@vhiguita said:
Hi,
I am implementing a ruby code that loads me a sketchup file(skp), this is my code:
point = Geom;;Point3d.new 10,20,30 > transform = Geom;;Transformation.new point > model = Sketchup.active_model > entities = model.active_entities > path = Sketchup.find_support_file "chimney.skp", > "C;/Users/usuario/Downloads/pluginsketchUp/Sketchup/org.dworks.suide_1.0.0/exe/" > definitions = model.definitions > componentdefinition = definitions.load path > instance = entities.add_instance componentdefinition, transform > if (instance) > UI.messagebox instance > else > UI.messagebox "Failure" > endHow could I do, the file loads of a different path to "Components/Components Sampler/" or maybe of a specific url?.
Thanks in advance.
See this topic for similar idea.
(Suggest you use code block as above in your posts.)
-
Just set the path as a string
path = "C:/Users/Usuario/then_any/valid_path/to a/Folder/MyLovelyPony.skp"
If you use / as the file separator the path can be inside '' or "".
But if it's \ then use '' ... OR escape the \ as \ inside ""...
Loading from a file-path or from a url are handled different as set out in the API docs...
Note you can use File methods to find the model's folder or a file's basename or filetype...
model_path=File.dirname(model.path) model_name=File.basename(model.path, ".*") model_ext=File.extname(model.path)
You can also make new file-paths using
output=File.join(model_path, "MyOutputFile.txt")
For example this would make a txt file with the model, into which you could write some data...
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better đź’—
Register LoginAdvertisement