Test to create SolarPath Object

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Test to create SolarPath Object

Post by chakkree »

Test for start concept.
But Part.Circle is not clear round.
How to define number's segment of a circle.

SolarPath.py:

Code: Select all

"""
  SolarPath.py
"""


import FreeCAD , Draft  , Part
from  FreeCAD import Vector , Placement
from Units import Unit,Quantity



class SolarPath():
    def __init__(self, obj):
        obj.addProperty("App::PropertyPlacement","Placement","Base","")
        obj.addProperty("App::PropertyLength","R","SolarPath","Radius of Solr Path")
        obj.addProperty("App::PropertyLength","t","SolarPath","Thickness of Ring")

        obj.R = Quantity('20000 mm')
        obj.t = Quantity('1000 mm')

        obj.Proxy = self

    def onChanged(self, fp, prop):
        if prop == "R" or prop == "t":
            self.execute(fp)


    def execute(self, fp):
        Ext = Quantity('500 mm')
        R = fp.R
        R2 = R - fp.t
        geoms = []
        
        AxisX =Part.Line( Vector (R+Ext,0,0) ,Vector(-R-Ext,0,0) )
        geoms.append(AxisX.toShape()) 


        AxisY =Part.Line( Vector (0,R+Ext,0) ,Vector(0,-R-Ext,0) )
        geoms.append(AxisY.toShape()) 

        Circle1 = Part.Circle() 
        Circle1.Radius = R
        geoms.append(Circle1.toShape()) 

        Circle2 = Part.Circle() 
        Circle2.Radius = R2
        geoms.append(Circle2.toShape()) 

        
        for iAngle in range(0,360,15):
            if iAngle%90 > 0 :
                pl = Placement(Vector(0,0,0),Vector(0,0,1),iAngle  )
                tick = Part.Line( Vector (0,R2,0) ,Vector(0,R+Ext,0) )
                tick.rotate(pl)
                geoms.append(tick.toShape()) 

        for iAngle in range(0,360,5):
            if iAngle%15 > 0 :
                pl = Placement(Vector(0,0,0),Vector(0,0,1),iAngle  )
                minor_tick = Part.Line( Vector (0,R2,0) ,Vector(0,R,0) )
                minor_tick.rotate(pl)
                geoms.append(minor_tick.toShape()) 

        Repr = Part.Compound(geoms)
        Repr.Placement = fp.Placement
        fp.Shape = Repr


def makeSolarPath():
    doc = FreeCAD.activeDocument()
    if doc == None:
        doc = FreeCAD.newDocument()
    obj=doc.addObject("Part::FeaturePython","SolarPath") #add object to document
    obj.Label = "SolarPath"

    
    SolarPath(obj)
    obj.ViewObject.Proxy=0
    viewObject = Gui.ActiveDocument.getObject(obj.Name)
    viewObject.LineColor = (0.61,0.61,0.61)

    #ViewProviderBox(a.ViewObject)


makeSolarPath()
FreeCAD.ActiveDocument.recompute()
Attachments
Result-02.PNG
Result-02.PNG (137.39 KiB) Viewed 3387 times
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Test to create SolarPath Object

Post by DeepSOIC »

hi!
The circle is internally clear round. It's only displayed segmented, because only rendering of lines is possible.
You can increase the fidelity of display by changing Deviation property (view tab in property editor, or .ViewObject.Deviation from within a script).
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Test to create SolarPath Object

Post by chakkree »

Thank you so much. Very beautiful.
Attachments
SetDeviation.png
SetDeviation.png (181.48 KiB) Viewed 3342 times
User avatar
yorik
Founder
Posts: 13660
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Test to create SolarPath Object

Post by yorik »

Very cool! having a good solar path system would be very useful, keep working on this! ;)
damian
Posts: 583
Joined: Sun May 31, 2015 6:16 pm

Re: Test to create SolarPath Object

Post by damian »

Hello chakkree:

I like your idea of a solar path. I would like to follow your work.

Please, could you explain briefly the principle of your formulation?

I've been revisiting my old books and I think to remember that in order to place the sun on the sky (elevation and azimuth) it's necessary to apply the Benford and Bock formulation. In addition, it's possible to elaborate the stereographic projection of the solar path on a location over a year.

Your script seems to take a more direct way.

Thank you.
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Test to create SolarPath Object

Post by chakkree »

At first is that I want to build a grid object.
started to study with ArchAxis.py
I tested the command to create lines.

I do a search on google with the word 'gbXML'.
I found a Solar's Path image.
I created three-dimensional chart With lines and circles.It doesn't affect models.
Attachments
SearchImages.jpg
SearchImages.jpg (47.5 KiB) Viewed 3303 times
damian
Posts: 583
Joined: Sun May 31, 2015 6:16 pm

Re: Test to create SolarPath Object

Post by damian »

Good morning:
I do a search on google with the word 'gbXML'
Okey. I see a lot of examples there.
sunpath.png
sunpath.png (58.97 KiB) Viewed 3293 times
I created three-dimensional chart With lines and circles.It doesn't affect models
Okey. I reaffirm my interest.

Thank you.
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Test to create SolarPath Object

Post by chakkree »

I found forum in topic "shadows in the freecad viewport" by Mr.Yorik

"shadows in the freecad viewport " viewtopic.php?t=9663

Image
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Test to create SolarPath Object

Post by chakkree »

damian
Posts: 583
Joined: Sun May 31, 2015 6:16 pm

Re: Test to create SolarPath Object

Post by damian »

http://rhodesmill.org/pyephem/
Given a date and location on the Earth’s surface, it can compute the positions of the Sun and Moon, of the planets and their moons, and of any asteroids, comets, or earth satellites whose orbital elements the user can provide.
Post Reply