sketchucation logo sketchucation
    • Login
    1. Home
    2. zps222
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    Z
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 4
    • Posts 14
    • Groups 1

    zps222

    @zps222

    10
    Reputation
    1
    Profile views
    14
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    zps222 Unfollow Follow
    registered-users

    Latest posts made by zps222

    • RE: How to add coordinate into SU api

      @dan rathbun said:

      What about ??
      Sketchup.active_model.shadow_info['Latitude'] Sketchup.active_model.shadow_info['Longitude']

      I believe these are set by the Model Info > Location feature.

      Thank you Dan and Jim.
      Still, I can't figure it out.
      Simply as an example,

      # Access the Entities object
      model = Sketchup.active_model
      ent = model.entities
      
      # Create the 2-D shape of the axis
      axis = ent.add_face [0, -500, 0], [250, -433, 0],
                            [433, -250, 0], [500, 0, 0],
                            [433,250, 0], [250, 433, 0],
                            [0, 500, 0], [-250, 433, 0],
                            [-433, 250, 0], [-500, 0, 0],
                            [-433, -250, 0], [-250, -433, 0], [0, -500, 0]
      
      
      # Create the 3-D shape of the axis
      total_depth = -2060
      axis.pushpull total_depth
      
      #creat one simple 3-d vector, North at the bottom
      vector1 =ent.add_face [-500,0,0],[500,0,0],
                         [500,1500,0],[750,1500,0],
                         [0,2000,0],[-750,1500,0],
                         [-500,1500,0] 
      
      vector_depth=-50
      vector1.pushpull vector_depth
      

      Here is my simple code, if I want to they located at lat= 10, lon=10, how to manege it?

      Really appratiate.

      posted in Developers' Forum
      Z
      zps222
    • RE: How to add coordinate into SU api

      @dan rathbun said:

      By the way.. I've heard that Google Earth models have to be "approved".

      Is this so? Does a user see his uploaded model right away, or is it invisible until it's approved?
      Or is it only invisible to other users, until it's approved?

      Thanks Dan. I will try your code soon.

      For your question, I can instaneously see the model on google earth, but it's only confined in my laptop, not publiclly to the internet. If wanted to publicate it, as far as I know, there are 3 ways:
      the most comon way is to upload the model into "google 3D warehouse" to let people download them into to "local" google earth. The sencond way is to embed the google earth into the website and the locate the KMZ into the server, then on the website, people can see it. The third way is to get the permission to publize it into official google earth.

      posted in Developers' Forum
      Z
      zps222
    • RE: How to add coordinate into SU api

      @dan rathbun said:

      FYI

      • Positive Latitudes are North of the equator; Negative are South.
      • Positive Longitudes are East of the Prime Meridian; Negative are West.

      @zps222 said:

      Another question is, if I build a model, and want to set the bottom of the model at a centain depth in the ocean, how to manage it?

      First, open your Preferences dialog. Go to the Extensions panel.
      Check (turn ON,) the "Google Earth Ocean Modeling" extension.

      Then browse to the Sketchup directory: "Plugins/Ocean" and read the ruby script 'ocean.rb'

      It appears that you will need to move everything in your model, either:

      • above the [0,0,0] origin, if you wish to place the model relative to the ocean floor, OR* below the [0,0,0] origin, if you wish to place the model relative to the ocean surface.
        You will need to use the "Model on Ocean Floor" menu option that the Ocean extension adds to the Plugins menu.. BEFORE you upload the model to Google Earth.

      Thans Dan.
      I still can't figure it out.

      For example, this is my example code:

      # Create the new material
      mats = Sketchup.active_model.materials
      ct_mat = mats.add "Color_Texture"
      ct_mat.color = "Red"
      
      # Draw a Face and set its material
      ents = Sketchup.active_model.entities
      face = ents.add_face [1000, -1000, -5000], [1000, 1000, -5000], [-1000, 1000, -5000], [-1000, -1000, -5000]
      face.material = ct_mat
      face.pushpull -4000
      
      Sketchup.active_model.shadow_info['Latitude']=29.060
      Sketchup.active_model.shadow_info['Longitude']=-88.090
      
      Sketchup.active_model.export("c;/2.kmz",false)
      
      UI.openURL("c;/2.kmz")
      
      
      # Copyright 2005-2009, Google, Inc.
      
      # This script enables placing a model in Google Earth relative to the ocean floor,
      # instead of relative to ground (sea level).
      
      # Permission to use, copy, modify, and distribute this software for 
      # any purpose and without fee is hereby granted, provided that the above
      # copyright notice appear in all copies.
      
      # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
      # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
      # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
      #-----------------------------------------------------------------------------
      
      def is_on_floor_bottom
        return Sketchup.active_model.get_attribute("GeoReference", "onOceanFloor") == "true";
      end
      
      def toggle_ocean
        on_floor = !is_on_floor_bottom()
        puts on_floor
        if on_floor
          Sketchup.active_model.set_attribute "GeoReference", "onOceanFloor", on_floor.to_s;
        else
          Sketchup.active_model.attribute_dictionary("GeoReference").delete_key "onOceanFloor";
        end
      end
      
      menu = UI;;menu("Plugins");
      menu.add_separator;
      item = menu.add_item($oceanStrings.GetString("Model on Ocean Floor")) { toggle_ocean }
      menu.set_validation_proc(item) {
        is_on_floor_bottom() ? MF_CHECKED ; MF_UNCHECKED;
      }
      
      posted in Developers' Forum
      Z
      zps222
    • RE: An intereting question

      @jim said:

      I believe that may possible using the SDK.

      SDK: http://code.google.com/apis/sketchup/docs/downloadsdksubmit.html

      Forum: http://groups.google.com/group/su-sdk-fileshare/topics

      Thank you Jim, just one more question.
      Right now, I am using eclispe to recall the function of SU, but I can only operate in the conditions that 1st: in Windows, 2nd, the SU is open.
      My final destination is simply use any software like eclipse or something in MAC, and run my code without openning SU.
      So my question is, is the method you offered can be realized as what I intended?
      Thank you again

      posted in Developers' Forum
      Z
      zps222
    • An intereting question

      Is it possible that Only run the ruby script to build the model, without "openning" SketchUp. Just in the header to recall the library or something?

      posted in Developers' Forum
      Z
      zps222
    • RE: How to add coordinate into SU api

      @tig said:

      OK ❓ that's even easier... all you have to do is set the long/lat for the model to what you want them to be ?
      Sketchup.active_model.shadow_info['Latitude']=54.32 Sketchup.active_model.shadow_info['Longitude']=12.34
      πŸ€“

      Another question is, if I build a model, and want to set the bottom of the model at a centain depth in the ocean, how to manage it?
      Thanks

      posted in Developers' Forum
      Z
      zps222
    • RE: How to add coordinate into SU api

      @tig said:

      OK ❓ that's even easier... all you have to do is set the long/lat for the model to what you want them to be ?
      Sketchup.active_model.shadow_info['Latitude']=54.32 Sketchup.active_model.shadow_info['Longitude']=12.34
      πŸ€“

      Yes, Tig!! It works !!

      Thank you very very much~~

      Have a good day~~

      posted in Developers' Forum
      Z
      zps222
    • RE: How to add coordinate into SU api

      @tig said:

      Do you mean x=10, y=10 etc... or do you mean real long/lat coordinates?
      If you simply want to move things to x/y/z I suggest you make your new geometry inside a group
      ents=model.active_entities grp=ents.add_group() ent=grp.entities

      your 'ent' now takes the geometry inside the group 'grp'.

      NOW we transform the group

      pt=Geom::point3d.new(10,10,0) tr=Geom::Transformation.new(pt) grp.transform!(tr)

      The 'grp' then moves from where it is to [10,10,0] or whatever coordinates you say in 'pt'

      if you don't want the geometry to remain grouped then add

      grp.explode

      Thanks Tig. But I want to place my model into a real long/latitude coordinate. Not the default one.

      posted in Developers' Forum
      Z
      zps222
    • How to add coordinate into SU api

      Hi guys, if I build a model, and I want to export it into google earth, especially want to see it in a certain logitude and latitude, which means to add the coordinate into the modle it self.
      I know to change the KMZ can realize the same function, however, I just want realize it in ruby?
      So anyone can help me? Thank you.

      posted in Developers' Forum
      Z
      zps222
    • About generating KMZ using Ruby Script instead of "Click"

      In SketchUp, there is a method to generate a KMZ file and export to google earth. However, is there ant ruby coding to replace such click button?

      Thank you !

      posted in Developers' Forum
      Z
      zps222