Author Topic: Archeoastronomy and Sketchup  (Read 12482 times)

construsol

  • New Member
  • *
  • Posts: 20
    • View Profile
Re: Archeoastronomy and Sketchup
« Reply #15 on: May 08, 2010, 07:01:17 PM »
Gabriel:

No, it did not work. I was also thinking to talk about this at the Sketchucation forums. I want to ask you if you can do this. The reason is that I have addressed the need for this plugin at four of its forums and, although at the beginning I got great support and almost 1,500 views, finally the plug was never made and the four threads have been practically dead for weeks. So, if I start a fifth thread I think the chances to have a reply is slim. Maybe from a programmer?s fresh point of view we can have more chances of a reply. Can you do this? Thank you Gabriel for all your time and effort, I really appreciate it.


construsol

  • New Member
  • *
  • Posts: 20
    • View Profile
Re: Archeoastronomy and Sketchup
« Reply #16 on: May 09, 2010, 09:16:37 AM »
Gabriel:

As an update, I made  a copy of the Sketchup 7 folder to C:, and copy the plugin also. If it's in C: there is no little yellow lock problem. I run SU from this C: copy BUT the plugin itself still does not work. I'm thimking the problem will not reside in this yellow lock. Maybe if you can post this at the Sketchucation forum we can get some help. Regards.


construsol

  • New Member
  • *
  • Posts: 20
    • View Profile
Re: Archeoastronomy and Sketchup
« Reply #17 on: May 09, 2010, 09:25:59 AM »
.....and as another last update:

There are plugins in my SU that are running just fine AND show the little yellow lock, so it looks that this may not affect the functionality of the Altitude Azimuth plugin.

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 654
    • View Profile
Re: Archeoastronomy and Sketchup
« Reply #18 on: May 09, 2010, 07:06:20 PM »
OK, I'll ask the question on the SketchuCation forums sometime tomorrow morning. I think your correct in thinking that the yellow lock has nothing to do with the problem.


I have one last plugin attached to this post for you to try. If it doesn't work, then I'm completely out of ideas and will definitely have to ask.

Before I do though, I'd like to find out a couple of things which might be useful to the SketchuCation forum.

First, go to "Window" on the menu bar and open the Ruby Console. Once the console window is open, run the plugin and copy and paste any error messages that might appear and give them to me in your reply.

Also, what is the exact version of Sketchup you are you using? As an example, mine is 7.0.8657.
You can find this by going to "help" on the menu bar and clicking "About Sketchup."


I'm sorry that this hasn't gone well. If your computer was in the room with me, I could probably fix this problem is just a couple of minutes. Having to do it over the forums like this takes a lot more time.

construsol

  • New Member
  • *
  • Posts: 20
    • View Profile
Re: Archeoastronomy and Sketchup
« Reply #19 on: May 09, 2010, 10:36:06 PM »
Gabriel:

Here is the message of the Ruby Console with version 3 of the plugin:

Error: #<NoMethodError: undefined method `cos' for ROTATETOALTANDAZ:Module>
C:/Program Files/Google/Google SketchUp 7/Plugins/Rotate_to_Alt_and_Az3.rb:20:in `rotateobject'
C:/Program Files/Google/Google SketchUp 7/Plugins/Rotate_to_Alt_and_Az3.rb:76
C:/Program Files/Google/Google SketchUp 7/Plugins/Rotate_to_Alt_and_Az3.rb:76:in `call'

and SU version is:

7.1.6860

Thanks for your help.


Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 654
    • View Profile
Re: Archeoastronomy and Sketchup
« Reply #20 on: May 10, 2010, 04:51:28 AM »
I should have asked you to check the Ruby Console earlier because I think I found the problem. In the code where the altitude and azimuth are turned into a vector, I forgot to put "Math." in front of the "cos". I'm confused as to why this didn't cause an error for me also, which is why I didn't think to check that part of the code.

Quote
altitude = input[0].to_f
azimuth = input[1].to_f - 180#AZIMUTH IS  -180 TO SO THAT DASHED GREEN LINE (SOUTH) IS SEEN AS AZIMUTH = 0
z = Math.sin(altitude.degrees)
hyp = cos(altitude.degrees)
etc....


I installed an older version of Sketchup on my computer (Sketchup 6) and got the same error message when I ran the plugin. I fixed the "Math.Cos(altitude.degrees)", and it worked. There might be something wrong with the error checking in my version of Sketchup because the old plugin ran fine and without any error messages for me.

Anyway, I attached the updated plugin which should hopefully work now. If not, let me know and I'll try to fix it (again). Give me any error messages in the Ruby Console if it doesn't.

Once again, sorry for the trouble.

construsol

  • New Member
  • *
  • Posts: 20
    • View Profile
Re: Archeoastronomy and Sketchup
« Reply #21 on: May 10, 2010, 08:48:58 AM »
Looking at the console, I thought it was a math thing because it had cos' in it.

Well Gabriel, I'm happy to tell you that the plugin runs almost 100% great! The little thing that would make it just perfect is that 90 degrees of Altitude would be directly up above, and not parallel to the ground plane. If I leave the Altitude field in 0, the plane automatically turns vertical. If I'm not wrong, Altitude angle starts at the ground with 0 degrees and starts rising until it points directly upward at 90 degrees (see image). Can this be done?

Gabriel, the icing on the cake would be: can the Azimuth angle start, not at the green axis, but wherever the SU north is (yellow line)? Thanks.

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 654
    • View Profile
Re: Archeoastronomy and Sketchup
« Reply #22 on: May 11, 2010, 07:03:33 AM »
I made the changes you wanted and attached the updated plugin to this post.

I also added an option, which you didn't ask for, where you can change whether it is north or south is where the azimuth = 0. I use south as 0, but it can sometimes be useful to use north instead.

Additionally, the plugin now saves the last altitude and azimuth used.


Regarding the altitude question, the face should be perpendicular to the altitude if you want it to point directly at the object in the sky. I attached a couple of pictures to show you want I mean.

In these pictures, you can see a black line which represents the altitude angle for the object in the sky. The "0alt" picture shows how the plugin would rotate the face before I changed to work the way you asked and the "minus90alt" picture shows it after. You can see that the face in the "minus90alt" doesn't point at the object in the sky.



I went ahead and changed the plugin to work the way you asked because it could be that I misunderstood how you will be using it. If you want to change the altitude back to the way it was before though, all you have to do is delete the "-90" in the code where the altitude variable is assigned.

You can see in the quote below where to do this in the code. It's highlighted in blue.
Quote
#THIS CODE TURNS THE ALTITUDE AND AZIMUTH INTO A VECTOR###----------------------------------------
northsouth = 0
northsouth = -180 if input[2] == "South"
altitude = input[0].to_f - 90
azimuth = input[1].to_f + Sketchup.active_model.shadow_info["NorthAngle"] + northsouth
z = Math.sin(altitude.degrees)
etc...

Hopefully the changes I made will work on your computer. It works fine on mine, but, if you have any trouble, let me know.

Have Fun!
« Last Edit: May 11, 2010, 07:10:17 AM by Gabriel »

construsol

  • New Member
  • *
  • Posts: 20
    • View Profile
Re: Archeoastronomy and Sketchup
« Reply #23 on: May 11, 2010, 08:27:33 AM »
Gabriel:

You are right. Respect to the altitude issue the plug sholud work like in version 4 (Face perpendicular to altitude). I'm sorry.

Thank you for the option for using north or south. I have seen somo literature that sometimes uses South as a starting point.

I don't know if you noticed, but if the Azimuth is at 0 and input any angle in the Altitude field, the plane rotates accordingly, but it does not work the other way around. If you leave the Altitude field at 0 and input any angle in Azimuth, it wont rotate. What could be the problem?

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 654
    • View Profile
Re: Archeoastronomy and Sketchup
« Reply #24 on: May 11, 2010, 09:45:27 AM »
There technically isn't a problem. I just changed it because I thought that's how you wanted it. Like I said, you can change it back by deleting the "-90" as explained above.

You can either edit the plugin to fix it yourself, or just download the one I attached if you find editing the code yourself confusing.

construsol

  • New Member
  • *
  • Posts: 20
    • View Profile
Re: Archeoastronomy and Sketchup
« Reply #25 on: May 11, 2010, 12:33:37 PM »
Thanks for your reply Gabriel. Did you read the last part of my previous mail about the plane not rotating in Azimuth if Altitude is 0 degrees?

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 654
    • View Profile
Re: Archeoastronomy and Sketchup
« Reply #26 on: May 11, 2010, 02:16:06 PM »
Sorry, I misunderstood your message last time.

Which way did you decide to have the plugin set up? When the altitude is at zero, is the plane flat on the "ground" or is it perpendicular to it?

I have mine set up so that the plane is perpendicular to the ground when the altitude is at zero. Everything works fine for me when it's set up like this. If yours doesn't and you have the plugin setup like this, check to see if you have any error messages in the Ruby console again and give them to me.

When I have the plugin set up so that the plane is flat on the ground when the altitude = 0 though, it doesn't rotate for me either. If this is how you have it set up and it isn't working, then I don't think there is anything I can really do about it. This is just how the Ruby code works inside of Sketchup.


construsol

  • New Member
  • *
  • Posts: 20
    • View Profile
Re: Archeoastronomy and Sketchup
« Reply #27 on: May 12, 2010, 07:03:11 AM »

As see in image 01, the setup is that when 0 in altitude, the plane is perpendicular to the ground. If from then I input 90 altitude and 45 azimuth, the plane lays flat but does not rotate to 45, but to 0 (image 02). If altitude is changed just a fraction, azimuth then rotates to 45. The Ruby Console does not output any message at all and north is the green line.  Do you have the same behaviour?
« Last Edit: May 12, 2010, 07:05:05 AM by construsol »

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 654
    • View Profile
Re: Archeoastronomy and Sketchup
« Reply #28 on: May 12, 2010, 06:27:40 PM »
The plugin does the same thing to me too. I don't know how to fix it though. My best guess is that it has something to do with the way Sketchup handles rotation internally. There isn't anyway to go into Sketchup's code to edit it, and I wouldn't know where to start even if there was.

I guess we'll just have to avoid using 90 or -90 degree altitude angles whenever possible. If one must be used though, it is still, of course, possible to rotate the face manually.

construsol

  • New Member
  • *
  • Posts: 20
    • View Profile
Re: Archeoastronomy and Sketchup
« Reply #29 on: May 12, 2010, 07:54:22 PM »
Ok.

All that is left for me right now is to give you a big Thank You for all your time and effort for making this plug-in. You have been a really big help. What I'm going to do is, beside using the plugin a lot, is to study how you wrote the script and to further study more about Ruby so I can make some changes as ideas may come to mind. I have a couple of preliminary ideas, the first I think is simpler to achieve than the second:

a) When selecting the plane, I would like that the plane AND its conecting geometry rotates with it. A similar script, Face Sun, already makes this, so I will take a look at it:

http://forums.sketchucation.com/viewtopic.php?f=323&t=27499

b) Would like to know if sotware that is freely available in the web that calculates Azimuth and Altitude for celestial bodies can run inside Sketchup, so a spreadsheet can be managed with a list of celestial bodies, input the time and location and the corresponding AZ and Alt are outputed.


I'm really looking forward for buying the "Automatic Sketchup" book, I think it can be a really useful. I'm reading right now this one:
http://www.amazon.com/Learn-Program-Pragmatic-Programmers-Chris/dp/0976694042

Thanks again Gabriel.
« Last Edit: May 12, 2010, 08:02:50 PM by construsol »