Sketching by importing coordinates

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
Debasish19
Posts: 11
Joined: Thu Aug 11, 2022 2:13 pm

Sketching by importing coordinates

Post by Debasish19 »

FreeCAD version -

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20

Problem Statement [A rough description of what I want to design using the FreeCAD] -

Consider an irregular cylindrical tube. I have the tube length and the x-y coordinates of the start and end cross-sections [assume ten coordinates for each cross-section in a txt file]. I am struggling with how to build these kinds of models with FreeCAD. Or it's not possible at all.

I have an idea of what I should be doing, but I am not sure how to do it-
Create a body -> Start a sketch -> Select a plane -> Import coordinates to connect and create the first cross-sectional plane -> Create a second sketch and follow the same to create the second cross-sectional plane. Then use the "loft" option to connect both sketches.

But I am not sure how to import coordinates to sketch. Could you please help me or provide some ideas to solve this problem.

Experience with FreeCAD -
I am new to FreeCAD and building CAD models. This is my first post here. I am sorry if I am breaking any forum rules here.
User avatar
NewJoker
Veteran
Posts: 3018
Joined: Sun Oct 11, 2020 7:49 pm

Re: Sketching by importing coordinates

Post by NewJoker »

Try using Draft Point - you can specify coordinates manually or with Python scripting. Then you could convert these points to sketches for further operations but keep in mind that sketches have to be planar - all points for a single sketch must lie in the same plane. But maybe conversion to sketches won’t be necessary.
edwilliams16
Veteran
Posts: 3107
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Sketching by importing coordinates

Post by edwilliams16 »

Make Wires from your imported points, then use Part.Loft in the Gui (or script it) to loft them together

Code: Select all

from math import sin, cos, pi
import Draft, Part
V3 = App.Vector
doc = App.ActiveDocument
npts = 20
thetas = [i * 2 * pi/npts for i in range(npts)]
r1 = 10
circle1 = [r1 * V3(cos(theta), sin(theta), 0) for theta in thetas]
wire1 = Draft.makeWire(circle1, closed = True)
r2 = 20
circle2 = [r2 * V3(cos(theta), sin(theta), 1) for theta in thetas]
wire2 = Draft.makeWire(circle2, closed = True)
doc.recompute()
Above I synthesized the points. You'll need to read them in from your file. The Points workbench might be useful in this regard.
edwilliams16
Veteran
Posts: 3107
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Sketching by importing coordinates

Post by edwilliams16 »

If you want a smooth fit through your imported points, you can use a Draft BSpline instead

Code: Select all

from math import sin, cos, pi
import Draft, Part
V3 = App.Vector
doc = App.ActiveDocument
npts = 20
thetas = [i * 2 * pi/npts for i in range(npts)]
r1 = 10
circle1 = [r1 * V3(cos(theta), sin(theta), 0) for theta in thetas]
#wire1 = Draft.makeWire(circle1, closed = True)
bs1 = Draft.makeBSpline(circle1)
r2 = 20
circle2 = [r2 * V3(cos(theta), sin(theta), 1) for theta in thetas]
#wire2 = Draft.makeWire(circle2, closed = True)
bs2 = Draft.makeBSpline(circle2, closed = True)
doc.recompute()

Debasish19
Posts: 11
Joined: Thu Aug 11, 2022 2:13 pm

Re: Sketching by importing coordinates

Post by Debasish19 »

Thanks @edwilliams16 and @NewJoker for answering my question and sharing the code. I will give it a try and let you know.
kohnagha
Posts: 76
Joined: Tue Dec 25, 2018 1:47 am

Re: Sketching by importing coordinates

Post by kohnagha »

--> Import your coordinates into Points-WB.
--> Convert pointClouds to BSplines with "Aproximate"-Tool in Curves-WB. Adjust Splines in General-Section of Spline-Data-Tab (close spline, ...).
--> Make a Loft in Part-WB (look that Start/EndPoints of Start/EndSplines are nearby to avoid twisting).


01.jpg
01.jpg (92.09 KiB) Viewed 583 times
Post Reply