# CompatibilityΒΆ

Most of the time, users experience problems in converting data between different software packages. To aid this problem a little bit, NURBS-Python provides a compatibility module for converting control points sets into NURBS-Python compatible ones.

The following example illustrates the usage of compatibility module:

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64``` ```from geomdl import NURBS from geomdl import utilities as utils from geomdl import compatibility as compat from geomdl.visualization import VisMPL # # Surface exported from your CAD software # # Dimensions of the control points grid p_size_u = 4 p_size_v = 3 # Control points in u-row order p_ctrlpts = [[0, 0, 0], [1, 0, 6], [2, 0, 0], [3, 0, 0], [0, 1, 0], [1, 1, 0], [2, 1, 0], [3, 1, -3], [0, 2, -3], [1, 2, 0], [2, 2, 3], [3, 2, 0]] # Weights vector p_weights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] # Degrees p_degree_u = 3 p_degree_v = 2 # # Prepare data for import # # Combine weights vector with the control points list t_ctrlptsw = compat.combine_ctrlpts_weights(p_ctrlpts, p_weights) # Since NURBS-Python uses v-row order, we need to convert the exported ones n_ctrlptsw = compat.flip_ctrlpts_u(t_ctrlptsw, p_size_u, p_size_v) # Since we have no information on knot vectors, let's auto-generate them n_knotvector_u = utils.generate_knot_vector(p_degree_u, p_size_u) n_knotvector_v = utils.generate_knot_vector(p_degree_v, p_size_v) # # Import surface to NURBS-Python # # Create a NURBS surface instance surf = NURBS.Surface() # Fill the surface object surf.degree_u = p_degree_u surf.degree_v = p_degree_v surf_set_ctrlpts(n_ctrlptsw, p_size_u, p_size_v) surf.knotvector_u = n_knotvector_u surf.knotvector_v = n_knotvector_v # Set evaluation delta surf.delta = 0.05 # Set visualization component vis_comp = VisMPL.VisSurface() surf.vis = vis_comp # Render the surface surf.render() ```

Please see Compatibility Module Documentation for more details on manipulating and exporting control points.

NURBS-Python has some other options for exporting and importing data. Please see File Formats page for details.