sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Giving images different name with export image

    Scheduled Pinned Locked Moved Newbie Forum
    sketchup
    3 Posts 2 Posters 350 Views 2 Watching
    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.
    • X Offline
      xi21lipa
      last edited by

      Hi, I'm working on 'export image' by myself and the result was not bad.

      Now, I'm trying to export some images with different name. The problem is, I already set up the specific name. I couldn't get next image with different name before I change the name in code.

      Maybe, I have to treat the name as variable but don't know how to do

      could you please help me with it? Here, I'm sharing the code

      require 'sketchup.rb'
      
          def exportimage
      
            model = Sketchup.active_model
            entities = model.entities
            view = model.active_view
      
            # Set the camera properties
            eye = [0, 0, -1000]
            target = [0, 0, 0]
            up = [0, 100, 0]
      
            # Create the camera and make it active
            cam = Sketchup;;Camera.new eye, target, up
            view.camera = cam
            view.zoom_extents 
      
            # Set file property
            keys = {
              # Naming file
              ;filename => "c;/temp/_image.png",
      
              # Pixel setting
              ;width => 500,
              ;height => 500,
      
              # Tranparent setting
              ;transparent => false
            }
            view.write_image keys
      
          end # def ExportImage
      
      #-----------------------------------------------------------------------------
      if( not file_loaded?("exportimage.rb") )
      add_separator_to_menu("Plugins")
      
      if $submenu!=nil
      $submenu.add_item("ExportImage") { exportimage }
      else
      UI.menu("Plugins").add_item("ExportImage") { exportimage }
      end
      end
      #-----------------------------------------------------------------------------
      file_loaded("exportimage.rb")
      
      

      with the code. All the name of images I produced was '_image'. I would like to get images have different name without changing the line "c:/temp/_image.png", in the code.

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by

        you can't not change that line, "c:/temp/_image.png" IS your image name...

        each new one will overwrite the previous...

        if you want different names that line has to change...

        john

        learn from the mistakes of others, you may not live long enough to make them all yourself...

        1 Reply Last reply Reply Quote 0
        • X Offline
          xi21lipa
          last edited by

          @unknownuser said:

          you can't not change that line, "c:/temp/_image.png" IS your image name...

          each new one will overwrite the previous...

          if you want different names that line has to change...

          john

          Then, what if I don't specify an image file path? Only the name and extension of image file will be remained and it looks like it can be treated... using #{name}

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

          Advertisement