automaticly share coincident topolgy #1839
-
I am trying to randomly build some objects on an existing object. While using SpaceClaim, I noticed a tool for sharing coincident topology: I also came across some prepare tools that seem to have similar functionality: However, after using the Is there an alternative way to achieve this? Or am I misunderstanding how these tools are supposed to work? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Hi @magicprograming - based on the error message you are getting, it seems to me that the version of PyAnsys Geometry that you are making use of does not have the method Would you be able to share a model where you are trying to apply a share topology? What version of Ansys are you making use of and what is your PyAnsys Geometry version (run Thanks in advance! |
Beta Was this translation helpful? Give feedback.
-
Thanks for your quick response! I really appreciate your help. Here are the details: Here is the model I used Here’s the code I’ve been using, where I attempt to add small buildings into the existing fluid region.Thanks again for taking the time to assist me! from ansys.geometry.core import launch_modeler
from ansys.geometry.core.designer.component import Component
from ansys.geometry.core.math import Plane, Point3D, Point2D, UnitVector3D
from ansys.geometry.core.misc import UNITS
from ansys.geometry.core.sketch import Sketch
from ansys.geometry.core.tools.prepare_tools import PrepareTools
from pint import Quantity
from enum import Enum
import numpy as np
#define layout
class layout_type(Enum):
in_line = 1
stagger = 2
manual_input = 3
urban_layout = layout_type.manual_input
#manual_input
input_position = [(25,10),(21,3),(20,8),(18,5),(14,7),(10,10),(8,4.5),(4.55,4.5)]
#design details
buildings_per_row = 4
buildings_per_col = 2
building_radius = 1.725 #in m
building_diameter = 2 * building_radius
building_height = 5.7 #in m
max_street_width = 2.35 #in m
#boundary conditions
boundary_x = 26.8
boundary_y_1 = 0.58
boundary_y_2 = 12
#number of building
if(urban_layout == layout_type.in_line or urban_layout == layout_type.stagger):
buildings_number = buildings_per_row * buildings_per_col
else:
buildings_number = 8
#check boundary conditions
for a in range(buildings_number):
x, y = input_position[a]
if (building_radius >= x) or(x >= boundary_x - building_radius) or (boundary_y_1 + building_radius >= y ) or ( y >= boundary_y_2 - building_radius):
print(f"ERROR:{input_position[a]} is out of boundaries")
break
#check overlap
for b in range(a + 1, buildings_number):
distance = np.linalg.norm(np.array(input_position[a]) - np.array(input_position[b]))
if distance < building_diameter:
print(f"ERROR:{input_position[a]} overlap with {input_position[b]}")
#start to create
modeler = launch_modeler()
design = modeler.open_file("New_Geom.scdoc")
# sketch building
building_sketch = Sketch()
building_sketch.circle(Point2D([0, 0], UNITS.m), Quantity(building_radius, UNITS.m))
building_body = design.extrude_sketch("Building", building_sketch, Quantity(building_height, UNITS.m))
#create position matrix
max_street_width += building_diameter
row_mid = (1+buildings_per_row)/2
col_mid = (1+buildings_per_col)/2
position = []
if(urban_layout==layout_type.in_line):
for i in range(1 , buildings_per_row+1):
for j in range(1 , buildings_per_col+1):
position.append(((i-row_mid) * max_street_width + 13.4 , (j-col_mid) * max_street_width + 6))
elif(urban_layout==layout_type.stagger):
for i in range(1, buildings_per_row + 1):
for j in range(1, buildings_per_col + 1):
position.append(((i-row_mid) * max_street_width + 13.4 , (j - col_mid) * max_street_width + (i % 2) * ((max_street_width)/2) + 6))
elif(urban_layout==layout_type.manual_input):
position = input_position
max_street_width -= building_diameter
buildings = []
#build the buildings
for i, (dx, dy) in enumerate(position, start=1):
new_building = building_body.copy(parent=design)
new_building.translate(UnitVector3D([1, 0, 0]), Quantity(dx, UNITS.m))
new_building.translate(UnitVector3D([0, 1, 0]), Quantity(dy, UNITS.m))
design.create_named_selection(f"cask_{i}", bodies = [new_building])
buildings.append(new_building)
design.delete_body(building_body)
#add fluid_air-fluid to the list
buildings.append(design.components[1].bodies[0])
#share topology
modeler.prepare_tools.share_topology(bodies = buildings, preserve_instances=True)
#export result
output_path = "Geom"
design.export_to_scdocx(output_path)
modeler.close() |
Beta Was this translation helpful? Give feedback.
-
Hi @RobPasMue , #add fluid_air-fluid to the list
buildings.append(design.components[1].bodies[0]) Additionally, I printed out the buildings list to confirm that it includes the fluid_air component. Despite this, the results still appeear to differ from what I observe when using the "Share Coincident Topology" function in SpaceClaim. For instance, after runing the code for However, if I then manually apply the "Share Coincident Topology" function in SpaceClaim, most of the parts that should be shared are still detected: This discrepancy leads me to wonder if I am missing some critical step or configuration in the Thanks again for your support! |
Beta Was this translation helpful? Give feedback.
I know that there were some tolerance issues when the value passed was 0. You can try to pass in a certain tolerance value just in case: https://geometry.docs.pyansys.com/version/stable/api/ansys/geometry/core/tools/prepare_tools/PrepareTools.html#PrepareTools.share_topology
Otherwise, I might have to reach out to some of my colleagues internally so that they can help you out. My knowledge on the internals of the SpaceClaim Share Topology feature are limited