• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Load Sketchup file from URL or Specific Diretory

Scheduled Pinned Locked Moved Newbie Forum
sketchup
3 Posts 3 Posters 292 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    vhiguita
    last edited by 20 Apr 2012, 18:19

    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"
    end

    How could I do, the file loads of a different path to "Components/Components Sampler/" or maybe of a specific url?.

    Thanks in advance.

    1 Reply Last reply Reply Quote 0
    • C Offline
      chrisglasier
      last edited by 26 Apr 2012, 07:22

      @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"
      >  end
      

      How 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.)

      With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

      1 Reply Last reply Reply Quote 0
      • T Offline
        TIG Moderator
        last edited by 26 Apr 2012, 09:46

        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...

        TIG

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          1/3
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement