@@ -95,6 +95,10 @@ def create_optical_property(self, name: str, description: str = "", metadata: Ma
9595 ansys.speos.script.opt_prop.OptProp
9696 OptProp feature.
9797 """
98+ existing_features = self .find (name = name )
99+ if len (existing_features ) != 0 :
100+ msg = "Feature {}: {} has a conflict name with an existing feature." .format (opt_prop .OptProp , name )
101+ raise ValueError (msg )
98102 feature = opt_prop .OptProp (project = self , name = name , description = description , metadata = metadata )
99103 self ._features .append (feature )
100104 return feature
@@ -130,6 +134,10 @@ def create_source(
130134 Union[ansys.speos.script.source.Surface, ansys.speos.script.source.RayFile, ansys.speos.script.source.Luminaire]
131135 Source class instance.
132136 """
137+ existing_features = self .find (name = name )
138+ if len (existing_features ) != 0 :
139+ msg = "Feature {}: {} has a conflict name with an existing feature." .format (feature_type , name )
140+ raise ValueError (msg )
133141 feature = None
134142 if feature_type == source .Surface :
135143 feature = source .Surface (project = self , name = name , description = description , metadata = metadata )
@@ -171,6 +179,10 @@ def create_simulation(
171179 Union[ansys.speos.script.simulation.Direct, ansys.speos.script.simulation.Interactive, ansys.speos.script.simulation.Inverse]
172180 Simulation class instance
173181 """
182+ existing_features = self .find (name = name )
183+ if len (existing_features ) != 0 :
184+ msg = "Feature {}: {} has a conflict name with an existing feature." .format (feature_type , name )
185+ raise ValueError (msg )
174186 feature = None
175187 if feature_type == simulation .Direct :
176188 feature = simulation .Direct (project = self , name = name , description = description , metadata = metadata )
@@ -212,6 +224,10 @@ def create_sensor(
212224 Union[ansys.speos.script.sensor.Camera, ansys.speos.script.sensor.Radiance, ansys.speos.script.sensor.Irradiance]
213225 Sensor class instance.
214226 """
227+ existing_features = self .find (name = name )
228+ if len (existing_features ) != 0 :
229+ msg = "Feature {}: {} has a conflict name with an existing feature." .format (feature_type , name )
230+ raise ValueError (msg )
215231 feature = None
216232 if feature_type == sensor .Irradiance :
217233 feature = sensor .Irradiance (project = self , name = name , description = description , metadata = metadata )
@@ -538,8 +554,9 @@ def _fill_features(self):
538554 self ._fill_bodies (body_guids = part_data .body_guids , feat_host = sp_feat )
539555
540556 for mat_inst in scene_data .materials :
541- op_feature = self .create_optical_property (name = mat_inst .name )
542- op_feature ._fill (mat_inst = mat_inst )
557+ if len (self .find (name = mat_inst .name )) == 0 :
558+ op_feature = self .create_optical_property (name = mat_inst .name )
559+ op_feature ._fill (mat_inst = mat_inst )
543560
544561 for src_inst in scene_data .sources :
545562 if src_inst .HasField ("rayfile_properties" ):
0 commit comments