My version is
OS: Windows 10 Version 2009
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24267 +148 (Git)
Build type: Release
Branch: Branch_0.19.4
Hash: 476ecf091941bead59b14e44afa6064d5a66afa3
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.3
Locale: Chinese/China (zh_CN)
I opened the dialog to execute a macro
Code: Select all
"""Sweep using a BSpline.
file: 20220606-sweep.py
Author: Carlo Dormeletti
Copyright: 2022
Licence: LGPL
"""
import os
import FreeCAD
import FreeCADGui
from FreeCAD import Vector, Rotation, Placement# noqa
import Part # noqa
DOC = FreeCAD.newDocument()
print(DOC)
def create_points(filename):
points = []
with open(filename,'r') as f:
data = f.readlines()
for line in data:
line.strip()
coords = [float(x) for x in line.split()]
points.append(Vector(*coords))
return points
def do_sweep(points):
bs = Part.BSplineCurve()
bs.buildFromPoles(points, False)
path = DOC.addObject("Part::Feature", "path")
path.Shape = bs.toShape()
DOC.recompute()
rad = 0.2
circle = Part.Circle(Vector(0, 0, 0), Vector(0, 0, 1), rad)
prof_dsp = Vector(0, 01.194835164932913862e+0, 0) #+ Vector(0, rad * 1, 0)
profile = DOC.addObject("Part::Feature", "profile")
profile.Shape = circle.toShape()
profile.Placement = Placement(prof_dsp, Rotation(0, 0, 0))
DOC.recompute()
sw_solid = DOC.addObject("Part::Sweep", "sweep")
sw_solid.Sections = (profile)
sw_solid.Spine = path
sw_solid.Solid = False
sw_solid.Frenet = False
DOC.recompute()
points = create_points(r"D:\Workspace\freeCAD\v_pole.asc")
print(f"From: {points[0]} to: {points[-1]}")
step = 40
points_s = points[::step]
points_s.append(points[-1])
do_sweep(points_s)
I reinstalled FreeCAD and it works now. Many thanks