Skip to main content

Editable ISO Mesh for Curves Workbench Part 1

I talked about creating a Rhino3D tween curve on my Patreon page a few weeks ago (https://www.patreon.com/posts/75954207) and an idea that I have to get this working as a macro in #FreeCAD. But I thought I try to make a few intermediary macros to get myself back into the swings of programming again.  I already created the 'curve to freehand b-spline' in a previous post but now I want to take this a step further and create a 'ISO curve to freehand b-spline mesh'.  This means that there would be a fully eatable mesh that can be lofted, approximated with some kind of NURBS surface such as a Gordan surfaced or even a plane loft or ruled surface.  Building it with Freehand B-Splines will allow a user to double clicking the individual curves to edit the mesh via the control points. 


The ISO surface interrogates a selected surface and creates a UV grid which follows the contours.  My idea is to take this ISO grid and make it fully editable as a mesh allow the resulting surface to be deformed.

Referring back to the code supplied by Chris G, the creator of the curves workbench in FreeCAD, the code to create a Freehand B-Spline is as follows:


from freecad.Curves import gordon_profile_FP as GP
sub = []
# If the Spline is snapped to other shapes
# add a link to these shapes. For example :
# sub = [(obj1, ("Edge1",)), (obj2, ("Face1",))]

# the interpolation points
pts = [FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(5, 0, 0), FreeCAD.Vector(10, 0, 0)]

# the type of each point.
# 0 = free point
# 1 = point snapped to a shape of the sub list
# For example, typ = [1, 0, 1]
# means that the first point will snap to the fist shape of the sub list
# and the third point will snap to the second shape
typ = [0, 0, 0]

fp = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "Freehand BSpline")
GP.GordonProfileFP(fp, [], pts, typ)
GP.GordonProfileVP(fp.ViewObject)
fp.recompute()

So far my code gets as far as creating the freehand b-splines for each of the edges of the ISO curves.  I have listed this as 'work in progress' below.  At the moment I create the mesh as per the selected ISO grid but I am still wondering how this is going to work and whether I should just allow for either U or V rather than both.  My thoughts is connect all U to V or vice versa as sub objects.  This will mean when one freehand b-spline is edited the sub objects will follow.  It might be worth colouring the splines that can be edited to distinguish them from each other.

This is what I have so far:

from freecad.Curves import gordon_profile_FP as GP 
s = Gui.Selection.getSelectionEx()[0]
o = s.Object
u = o.NumberU
v = o.NumberV
mode = "u"
numberOfControlPoints = v
count = 0
for edge in o.Shape.Edges :
count = count + 1
if mode != "v" and count > u:
mode = "v"
numberOfControlPoints = u

pts = edge.discretize(numberOfControlPoints) 
print(pts)
typ = [0] * numberOfControlPoints 

# Create the bspline. 
        # Name will be appended with a unique extension if already exists
fp = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "Freehand BSpline") 
GP.GordonProfileFP(fp, [], pts, typ) 
GP.GordonProfileVP(fp.ViewObject) 
fp.recompute()

Comments

  1. take a look at the SilkWB (https://github.com/edwardvmills/Silk). though not exactly what you are trying to do, the ControlGrids are similar in a way, and may be useful to incorporate into what you are doing

    ReplyDelete

Post a Comment

Popular posts from this blog

Beginners FreeCAD: Exercise 5.1 & 5.2 (Reference Images)

Welcome to the total beginners course to FreeCAD 0.20. In this is a two part lesson we will practice our tracing skill in the form of a mini project. Using the below reference photos we will create a more complex part which will consist of repeating features. We will utilise the symmetry tools to ease construction in both FreeCAD sketcher and Part Design workbench. This project work will help teach the fundamentals of freeCAD allowing a understanding of the basics but delivering this information via teaching you different workflows. In this tutorial we will be tracing photos imported into FreeCAD via the image workbench https://wiki.freecadweb.org/Image_Workbench JUMP TO IMAGES Do you want to purchase the complete series along with others and keep forever?  Check out my shop https://ko-fi.com/mang0/shop The story of this tutorial The idea and first attempt at creating this tutorial was back in FreeCAD 0.18.  The physical part itself, well, I have no idea what really it is, i...

FreeCAD For Beginners: CAD Thinking Part 1

Step-by-Step CAD Thinking FreeCAD Tutorial: Modeling a Latch Part (Part 1) Learning how to turn real life objects into CAD Models. Using FreeCAD we explain at a beginner level how to break down a physical object into its primitive shapes to digitise it into a 3D model, with this episode we are looking at a multi-part assembly, modelling each piece individually. The series aims to open your eyes and mind giving you the ground skills to pick the correct profiles, geometry and workflow when it comes to modelling your parts. This is not just for FreeCAD but for all CAD packages out there. Introduction This tutorial is the first in a series guiding you through modeling a latch assembly in FreeCAD (version 0.21) using the Part Design and A2Plus workbenches. It focuses on modeling the first part (a slotted component) by selecting the top profile to create a slot and adding side arcs, emphasizing CAD thinking to break down complex shapes into primitives. The tutorial highlights model stability...

Modeling Flowcharts For Basic Beginners FreeCAD v1

 Th following flowcharts are used in the Basic Beginners FreeCAD v1 course.  They consist of two flows, one for simplifying the model and one for identifying the individual features and how to model them.   The flowcharts can downloaded by clicking on them, they will then open in a new page, from there right click on the image and save as. Flowcharts can be found below.  Current flowchart version is version 1.0.0 Own my courses forever, check out my shop https://ko-fi.com/mang0/shop Own my courses forever,  check out my shop   https://ko-fi.com/mang0/shop