Model origin

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
wmayer
Site Admin
Posts: 14885
Joined: Thu Feb 19, 2009 10:32 am

Re: Model origin

Postby wmayer » Thu Dec 23, 2010 9:37 am

This is what I have now:
------------------->

I would like to have this:
=============>

Code: Select all

axis=axisCross.getPart("shape",0)
axis.set("xAxis.appearance.drawStyle", "lineWidth 2")
axis.set("yAxis.appearance.drawStyle", "lineWidth 2")
axis.set("zAxis.appearance.drawStyle", "lineWidth 2")
When I'm writing down final line in python console:
cone.bottomRadius.setValue(10)

when I write 'cone.' a list appears. Why is 'bottomRadius' not listed in this list? and where in documentation can I find 'bottomRadius'
The pivy is a python wrapper for the C++ library Coin3D (Open Inventor) using the tool SWIG. Obviously the generated code handles all the type-internal stuff on its own instead of following the official python way. That's why attributes don't appear in an object's type list and thus do not appear in the list. Unfortunately, I do nit know of any workaround to fix this misbehaviour.
User avatar
yorik
Site Admin
Posts: 11552
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Model origin

Postby yorik » Thu Dec 23, 2010 1:08 pm

Ah, that is specific to pivy. Normally, in python, you can indeed see all attributes and methods of an object. So when you write cone. the freecad python interpreter displays them for you. Now, in openInventor (pivy is a python implementation of coin which is an implementation of OpenInventor), objects can have what they call "fields" which are "more or less" like properties. Let's say its a concept specific to openInventor. I suppose that fields concept didn't render very well in python...

But see that, if you type cone.bottomRadius. then the options appear... I suppose python considers fields as a kind of shortcut...
pperisin
Posts: 695
Joined: Wed Oct 20, 2010 12:29 pm

Re: Model origin

Postby pperisin » Mon Dec 27, 2010 10:17 am

yorikvanhavre wrote:But see that, if you type cone.bottomRadius. then the options appear... I suppose python considers fields as a kind of shortcut...
Yes, I have seen this too.

Right now I have created a script and I have assigned it to toolbar button. The Script allows you to show/hide origin. Maybe there would be a better way to do this, but I'm just a beginner, so feel free to comment and help in improving it (and my Python knowledge :-) ).

Code: Select all

from pivy import coin
try:
    Gui.ActiveDocument.ActiveView.getSceneGraph().removeChild(axisCross)
except:
	axisCross=coin.SoType.fromName("SoShapeScale").createInstance()
	axisCross.setPart("shape", coin.SoType.fromName("SoAxisCrossKit").createInstance())
	axisCross.scaleFactor.setValue(0.3) # modify this value to make origin bigger or smaller
	axis=axisCross.getPart("shape",0)
	cone=axis.getPart("xHead.shape",0)
	cone.bottomRadius.setValue(15) # modify this value to make arrow wider or thinner
	axis.set("xAxis.appearance.drawStyle", "lineWidth 3")  # modify this three values
	axis.set("yAxis.appearance.drawStyle", "lineWidth 3")  # to make lines of origin
	axis.set("zAxis.appearance.drawStyle", "lineWidth 3")  # wider or thinner
	Gui.ActiveDocument.ActiveView.getSceneGraph().addChild(axisCross)
else:
    del axisCross 
You can assign this macro to Menu item or toolbar botton, and every time you click on it origin will appear/Disappear
User avatar
jdurston
Posts: 86
Joined: Sun Oct 16, 2011 8:12 pm
Location: Bristol, UK
Contact:

Re: Model origin

Postby jdurston » Sun Apr 08, 2012 9:37 pm

pperisin wrote: Right now I have created a script and I have assigned it to toolbar button. The Script allows you to show/hide origin. Maybe there would be a better way to do this, but I'm just a beginner, so feel free to comment and help in improving it (and my Python knowledge :-) ).
Thats cool - I'm using FreeCAD 0.13 0784(Git) and there is a menu entry: View -> Toggle axis cross
Is this your script? How can I view the source file to check?
pperisin
Posts: 695
Joined: Wed Oct 20, 2010 12:29 pm

Re: Model origin

Postby pperisin » Tue Apr 10, 2012 6:24 am

yes, partially.

IIRC, this script will modify axis cross in a way it will appear as infinite axes lines, similar to those in Sketchup.

It is not perfect, but usable.

Regards
Petar
franzengel
Posts: 29
Joined: Wed May 30, 2012 11:26 am

Re: Model origin

Postby franzengel » Thu Feb 28, 2013 6:02 pm

Is it also possible to rotate and to move the coordinatesystem. I would like to use it to show the orientation of the waypoints of my robot trajectories. So the best way for me it would be to multiply the coordinatesystem with my homogenous matrix. Is this possible?

regards,
Franz
dam5h
Posts: 30
Joined: Mon Feb 11, 2013 4:24 pm

Re: Model origin

Postby dam5h » Thu Feb 28, 2013 9:10 pm

You can try typeing "cone." with a period at the end and then use the autocomplete dialog that pops up to see the different methods and attributes of the "cone" object.