Model.surfaceprimitivefromlines#
- Model.surfaceprimitivefromlines(collection, surf_type, tol_mode, tol, options)#
Takes input lines and uses them as targets to construct surface of specified primitive type. Optionally, tolerance value can be specified to reject surface that does not fit input lines.
- Parameters:
collection (Collection) – The collection containing the line entities.
surf_type (int) –
The type of primitive surface to create. Valid values are:
1 - plane
2 - sphere
3 - cylinder
4 - cone
5 - general quadric surface
For
surf_type=4, if a cylinder can be fit to the input entities, it will be created instead of a cone.tol_mode (int) –
0 - Tolerance is not used, best possible surface is found for any input set of points.
1 - Tolerance specified by
tolparameter is used to reject surface that does not fit input points.tol (double) – Tolerance value used to accept generated surface. Not used if
tol_mode=0. Negative value can be set to specify that the global value of the geometry cleanup tolerance set usehm.setoption(cleanup_tolerance=...).options (int) –
Flags that indicate different modes.
Bit values are used and the value is calculated as (Bit0 + 2*Bit1). Valid Bit options are:
Bit0
Trimming mode. Valid values are:
0 - An untrimmed surface is created.
1 - Created surface is trimmed by input lines and automatically stitched to adjacent surfaces.
In this case, the value of
tol_modeshould be set to 1.Bit1
Specifies how entities are organized into components. Valid values are:
0 - Surface is created in the current component.
1 - Surface is created in the most common input lines component.
Show Bit value calculator
Radio Button Table Option Name Value Trimming mode (Bit0) Specifies how entities are organized into components (Bit1) Calculated argument value: 0
Examples#
Create a cone surface that fits all displayed lines in the best possible way#import hm import hm.entities as ent model = hm.Model() model.surfaceprimitivefromlines( collection=hm.CollectionByDisplayed(model, ent.Line), surf_type=4, tol_mode=0, tol=0.0, options=0, )
Try to create a sphere that fits the lines with IDs 1 through 8 with a deviation not larger than 0.02 , and trim the resulted surface with the input lines#import hm import hm.entities as ent model = hm.Model() # Creating a collection that contains the lines with IDs 1-8 filter_lines = hm.FilterByEnumeration(ent.Line, list(range(1, 9))) lines_collection = hm.Collection(model, filter_lines) model.surfaceprimitivefromlines( collection=lines_collection, surf_type=2, tol_mode=1, tol=0.02, options=1 )