can extract a edge to a sketch?

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!
Post Reply
eexpss
Posts: 56
Joined: Wed Dec 28, 2016 6:17 am

can extract a edge to a sketch?

Post by eexpss »

I want extract this preselected edge into a sketch, at same position.

If I draw another new sketch, it hard to align the same position with same radium. So I want just extract (export) it.
Attachments
2017-03-10 08-38-27屏幕截图.png
2017-03-10 08-38-27屏幕截图.png (18.65 KiB) Viewed 3822 times
mario52
Veteran
Posts: 4692
Joined: Wed May 16, 2012 2:13 pm

Re: can extract a edge to a sketch?

Post by mario52 »

hi
use this macro Macro_Repro_Wire (select the wire and launch the macro)

and this macro for convert the wire in circle (select the wire and launch the macro)

Code: Select all

import Draft
from FreeCAD import Base
from FreeCAD import Vector
selectionObjects = FreeCADGui.Selection.getSelectionEx()               # Select an object or sub object getSelectionEx
for selection in selectionObjects:
    for selectedEdge in selection.SubObjects:
        if (str(selectedEdge.Curve)[0:6]  == "Circle"):
            pl = selectedEdge.Placement
            pl.Base=FreeCAD.Vector(selectedEdge.Curve.Center)
            pl.Rotation.Q = App.Rotation(App.Vector(0,0,1),selectedEdge.Curve.Axis).Q
            cercle = Draft.makeCircle(radius=selectedEdge.Curve.Radius, placement=pl, face=False, support=None)

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
eexpss
Posts: 56
Joined: Wed Dec 28, 2016 6:17 am

Re: can extract a edge to a sketch?

Post by eexpss »

mario52, thanks, it work.

but I got a sketch? or a face? it not a circle anymore. I can not edit as circle. when I edit, I got this edit box.
Attachments
2017-03-10 21-26-43屏幕截图.png
2017-03-10 21-26-43屏幕截图.png (17.73 KiB) Viewed 3795 times
chrisb
Veteran
Posts: 54213
Joined: Tue Mar 17, 2015 9:14 am

Re: can extract a edge to a sketch?

Post by chrisb »

eexpss wrote: If I draw another new sketch, it hard to align the same position with same radium. So I want just extract (export) it.
If you select the planar face next to the selected circle and then create a sketch in Part Design the sketch is attached to that face. You can use external geometry to select the circle. That gives you the center and the radius, which is all you need for a circle.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
eexpss
Posts: 56
Joined: Wed Dec 28, 2016 6:17 am

Re: can extract a edge to a sketch?

Post by eexpss »

chrisb wrote:
eexpss wrote: If I draw another new sketch, it hard to align the same position with same radium. So I want just extract (export) it.
If you select the planar face next to the selected circle and then create a sketch in Part Design the sketch is attached to that face. You can use external geometry to select the circle. That gives you the center and the radius, which is all you need for a circle.
Yes, I know this. but I can not snap the circle to the external circle. I just can align the center point of the circle.
Attachments
out-1.ogv.gif
out-1.ogv.gif (268.96 KiB) Viewed 3784 times
chrisb
Veteran
Posts: 54213
Joined: Tue Mar 17, 2015 9:14 am

Re: can extract a edge to a sketch?

Post by chrisb »

Select both circles and apply the equality constraint "=".
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
eexpss
Posts: 56
Joined: Wed Dec 28, 2016 6:17 am

Re: can extract a edge to a sketch?

Post by eexpss »

chrisb wrote:Select both circles and apply the equality constraint "=".
I forgot this. goooood idea. thanks.
chrisb
Veteran
Posts: 54213
Joined: Tue Mar 17, 2015 9:14 am

Re: can extract a edge to a sketch?

Post by chrisb »

You're welcome.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply