Friday, 13 June 2014

FreeCAD: Inline-Four engine animation

Another more-less simple engine animation:




Find the errors, there are a lot of them!
:D

Sorry, no files or code this time, but keep in mind this is as difficult as this one


Bye!

Thursday, 12 June 2014

Bash: Execute script in a terminal at startup

Today I was wondering how could I monitor the temperatures of my computer automatically, using something that runs at startup without doing anything manually.

This is the result:


A terminal with transparent background that shows the temps.

Code:

The code to display sensor values and update them two times per second is:

while [ 1 ]; do 
sensors;                                  # Outputs cpu and motherboard temps
aticonfig --odgt;                     # Outputs my AMD GPU temps.
sleep 0.5;                               # Delay for 0.5 seconds
done

Save it somewhere as .sh and give execution permissions.

To run the code above (or any other you want) in a terminal:

gnome-terminal --profile=cristal --zoom=0.85 --geometry=60x16+1920+0 -x PATH

I've set previously a new profile of gnome-terminal (called "cristal") that has transparent background and "Temperaturas" as window label.
Then, using the --profile option I set that profile for the new terminal.

The option --zoom=0.85 reduces the terminal size at 85%  (genius)

The parameter --geometry is more interesting:

Columns x Lines + Xposition + Yposition

The position is given by your screen resolution. On my screen, the window is in the upper right corner when X = 1920 and Y=0

And finally, PATH is the absolute path to the code you want to execute.


To execute at startup, go to "startup applications", add a new application and where it says "command", paste the line that starts "gnome-terminal --profile......" customized to suit your particulad needs.
Save it and you are done.

Bye!

Saturday, 31 May 2014

FreeCAD: Vertex to Vertex Positioning Function

FreeCAD 0.14 is taking too long to be released and, if when you try to compile it, everything is a non-sense and you end up feeling frustrated and stupid (as happens to me every time), you may like this:

Frustration solved: Hamish Assembly2 workbench here

Vector to Vector translation function:

 

Code:

from FreeCAD import Gui

def V2V():
  MouseSel = Gui.Selection.getSelectionEx()
  ObjA_Name = MouseSel[0].ObjectName
  PointA = MouseSel[0].SubObjects[0].Point
  PointB = MouseSel[1].SubObjects[0].Point
  Vector = PointB - PointA
  Pos0 = App.ActiveDocument.getObject(ObjA_Name).Placement.Base
  Rot0 = App.ActiveDocument.getObject(ObjA_Name).Placement.Rotation
  MVector = Pos0 + Vector
  App.ActiveDocument.getObject(ObjA_Name).Placement = App.Placement(MVector, Rot0)

 To Use it:

Copy-Paste at FreeCAD command line the code above and then:

-Select a point of the object you want to move
-Select a point of another object where you want the previous one to be placed
-Call the function (write V2V() at command line and Enter)

And you're done!


With this you can save some time when placing objects without the assembly workbench. 


Bye!