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 -
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.
-
zps222, please wrap your code in a code block.
Edit your post. Hilite the entire ruby text, and click the code button on the Edit Toolbar.
. -
- Wrap your script in a unique module. 1. Do NOT paste the entire 'ocean.rb' into your script. Instead, use
require
to make sure it's loaded.
module Zps222 module OceanTest require('Ocean/ocean.rb') # your code # do this BEFORE exporting model for surface ref # change the 'if' to 'unless' for bottom ref toggle_ocean() if is_on_floor_bottom() Sketchup.active_model.export("c;/2.kmz",false) UI.openURL("c;/2.kmz") end end
Also you need to start using ( ) around your argument lists.
This can confuse Ruby:
face.pushpull -4000
Ruby may think you are trying to subtract integer 4000 from an object returned by the method on the left. Do this instead:
face.pushpull(-4000)
. - Wrap your script in a unique module. 1. Do NOT paste the entire 'ocean.rb' into your script. Instead, use
-
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? -
@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; }
-
@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. -
@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.
-
zps222,
The description of the Google Earth Ocean Modeling extension says,
"Adds the ability to model on the ocean floor after taking a snapshot from Google Earth."So try taking a shapshot first.
-
.
Here's some commands you can use at the console, for info:dicts=Sketchup.active_model.attribute_dictionaries dicts['GeoReference'].each { |key,value| p key.to_s + '=' + value.to_s }
-
how can i put a simple model in the required location? i did the following coding
model = Sketchup.active_model
pt = Geom::point3d.new(0,0,0)
tr = Geom::Transformation.new(pt)
model.transform!(tr)and it gives me this error:
#<NoMethodError: undefined method `point3d' for Geom:Module>thankss
-
@borg.stef said:
... and it gives me this error:
#<NoMethodError: undefined method
point3d' for Geom:Module>`Because methods begin with lower case identifiers.
Class (and Module,) indentifiers are titlecase.@borg.stef said:
How can i put a simple model in the required location? I did the following coding:
model = Sketchup.active_model pt = Geom::point3d.new(0,0,0) tr = Geom::Transformation.new(pt) model.transform!(tr)
The model origin is already at [0,0,0], and there is a constant
ORIGIN
for it.
So your code above does nothing.
Advertisement