FreeCad cartesian coordinates
Forum rules
and Helpful information
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!
Also, be nice to others! Read the FreeCAD code of conduct!
-
- Posts: 8
- Joined: Wed Jul 03, 2013 8:35 am
FreeCad cartesian coordinates
Hi all,
I'm a new member of this forum, and I was wondering if you guys can help me with the following problem.
I have a drwaning of a lens in a step file, and i would like to have the cartesian coordinates of the crosssection cut.
Preferably something like :
x=34. z=1.56443
x=33.99 z=1.5633
x=33.98 z=1.5600
x=33.97 z=1.5587
And so on untill the end/side of the lens is reached.
Is it possible to get these coordinates? Is this a common problem?
Can anybody give me an example how to write tis in Delpi?
I'm also new to this
Thank you
I'm a new member of this forum, and I was wondering if you guys can help me with the following problem.
I have a drwaning of a lens in a step file, and i would like to have the cartesian coordinates of the crosssection cut.
Preferably something like :
x=34. z=1.56443
x=33.99 z=1.5633
x=33.98 z=1.5600
x=33.97 z=1.5587
And so on untill the end/side of the lens is reached.
Is it possible to get these coordinates? Is this a common problem?
Can anybody give me an example how to write tis in Delpi?
I'm also new to this
Thank you
Re: FreeCad cartesian coordinates
I'm not sure I understood clearly, what you want is to take a 2D curve, and get a series of points on that curve? You need to do that in python scripting, but it is totally possible. I give here an example, you'll need to adapt to your own situation. Let's say you have your object, and you already made a cutplane and placed it correctly (your cur plane must be larger than the object to cut) and already made a section of them, and that section object is called "MySection", and you want a point every 10 units:
Code: Select all
obj = FreeCAD.ActiveDocument.MySection
for edge in obj.Shape.Edges:
numberOfPoints = int(edge.Length/10)
intervals = range(0,numberOfPoints)
intervals.append(edge.Length)
for i in intervals:
point = edge.valueAt(i*10)
print "point at length "+ str(i) + " : x=" + str(point.x) + " y=" + str(point.y) + " z=" + str(point.z)
-
- Posts: 8
- Joined: Wed Jul 03, 2013 8:35 am
Re: FreeCad cartesian coordinates
Thank you for your help
Im realy a newbe, how do I make a cut ?
Maybe i'm making the right cut, but I get a error on line 1, But I cant read the error. Are you sure the code you give me is correct?
I have called the section "mysection" like you suggested. I have atached a screen of the problem.
Please Help
Im realy a newbe, how do I make a cut ?
Maybe i'm making the right cut, but I get a error on line 1, But I cant read the error. Are you sure the code you give me is correct?
I have called the section "mysection" like you suggested. I have atached a screen of the problem.
Please Help
-
- Posts: 8
- Joined: Wed Jul 03, 2013 8:35 am
Re: FreeCad cartesian coordinates
Try agian to attache the pic of my screen.
Re: FreeCad cartesian coordinates
if the line 1 gives an error it means there is no object called "MySection" in your document. Probably it has another name, you'd better not modify its default name and use that name in the script. Be careful that it is case-sensitive.
To make a cut you basically make one object to cut, then a plane that will act as a section plane, it must be bigger than the object to cut, then you select both and use the "Section" tool in the Part module...
Attaching images to the forum doesn't work at the moment (sourceforge did something wrong and never fixed), you need to host your images somewhere else and use a link, if you want to post images.
To make a cut you basically make one object to cut, then a plane that will act as a section plane, it must be bigger than the object to cut, then you select both and use the "Section" tool in the Part module...
Attaching images to the forum doesn't work at the moment (sourceforge did something wrong and never fixed), you need to host your images somewhere else and use a link, if you want to post images.
Re: FreeCad cartesian coordinates
Gerald,
Please explain why you posted here in "Open discussion (Open discussion about the future of FreeCAD)" instead of in "Help on using FreeCAD (This is the board to ask for help USING FreeCAD)".
This is a help request is it not?
Please explain why you posted here in "Open discussion (Open discussion about the future of FreeCAD)" instead of in "Help on using FreeCAD (This is the board to ask for help USING FreeCAD)".
This is a help request is it not?
Re: FreeCad cartesian coordinates
Here is a simple example:
Code: Select all
import Part
from FreeCAD import Base
c=Part.makeCylinder(2,10)
# slice accepts two arguments:
#+ the normal of the cross section plane
#+ the distance from the origin to the cross section plane. Here you have to find a value so that the plane intersects your object
s=c.slice(Base.Vector(0,1,0),0)
# here the result is a single wire
# depending on the source object this can be several wires
s=s[0]
# if you only need the vertexes of the shape you can use
v=[]
for i in s.Vertexes:
v.append(i.Point)
# but you can also sub-sample the section to have a certain number of points (int) ...
p1=s.discretize(20)
# ... or define a sampling distance (float)
p2=s.discretize(0.5)
Re: FreeCad cartesian coordinates
Yes, much better example, sorry, my explanations were a bit sparse...
-
- Posts: 8
- Joined: Wed Jul 03, 2013 8:35 am
Re: FreeCad cartesian coordinates
This is a help request, shall i move this thread to the help section?
Still after many weeks of practise I still can not export the cardesian coordinates !
Now I know how to cut the part in half, I can select the curve I want exported, but I have no idea how to export this... please help me with this (for me) difficult problem
Here is a screenshot of the stepfile I would like to export the cardesian coordinates, the selected curve I would like to export.
http://www.freebits.nl/images/332cad.jpg
The only thing I need is the coordinates something like this
X24.896813 Z0.149248
X24.896438 Z0.149152
X24.895688 Z0.148959
X24.892688 Z0.148188
enz enz
Still after many weeks of practise I still can not export the cardesian coordinates !
Now I know how to cut the part in half, I can select the curve I want exported, but I have no idea how to export this... please help me with this (for me) difficult problem
Here is a screenshot of the stepfile I would like to export the cardesian coordinates, the selected curve I would like to export.
http://www.freebits.nl/images/332cad.jpg
The only thing I need is the coordinates something like this
X24.896813 Z0.149248
X24.896438 Z0.149152
X24.895688 Z0.148959
X24.892688 Z0.148188
enz enz
Re: FreeCad cartesian coordinates
Ok I'll adapt Werner's example to this case. The following code will give you 10 points from a selected edge. You can paste this code in a macro, so it's easy to reuse, or paste the code directly in the python window. Change the value of numberOfPoints if you want a different number or points:
Code: Select all
numberOfPoints = 10
selectedEdge = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[0].copy()
points = selectedEdge.discretize(numberOfPoints)
for p in points:
print "X", p.x, " Y", p.y, " Z", p.z