Created
July 8, 2020 06:52
-
-
Save aegis1980/a6cbc474af6d6f979f0dcb5ed4047e19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shapely.geometry as sg | |
import sectionproperties.pre.sections as sections | |
from sectionproperties.analysis.cross_section import CrossSection | |
import dxf | |
import utils | |
#change to fp of your dxf | |
dxf_filepath = os.path.join(os.getcwd(),'example_files','section_holes_complex.dxf') | |
my_dxf = dxf.DxfImporter(dxf_filepath) | |
my_dxf.process() | |
my_dxf.cleanup() | |
polygons = my_dxf.polygons | |
new = utils.find_holes(polygons) | |
hole_cps = [] | |
for hole in new.interiors: | |
p = utils.point_in_polygon(sg.Polygon(hole)) | |
hole_cps.append([p.x,p.y]) | |
# create the custom geometry object | |
points = [list(elem) for elem in list(zip(new.exterior.xy[0],new.exterior.xy[1]))] | |
cp = utils.point_in_polygon(new) | |
for hole_lr in new.interiors: | |
pts = [list(elem) for elem in list(zip(hole_lr.xy[0],hole_lr.xy[1]))] | |
points.extend(pts) | |
facets = utils.facets(new,inc_holes=True) | |
geometry = sections.CustomSection(points = points, facets=facets, holes =hole_cps, control_points=[[cp.x,cp.y]] ) | |
geometry.clean_geometry() # clean the geometry | |
geometry.plot_geometry() # plot the geometry | |
# create the mesh - use a smaller refinement for the angle region | |
mesh = geometry.create_mesh(mesh_sizes=[1]) | |
print('done mesh') | |
# create a CrossSection object | |
section = CrossSection(geometry, mesh) | |
print('done section') | |
section.plot_mesh() # plot the generated mesh | |
# perform a geometric, warping and plastic analysis | |
section.calculate_geometric_properties() | |
section.calculate_warping_properties() | |
section.calculate_plastic_properties(time_info=True) | |
# plot the centroids | |
section.plot_centroids() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment