Skip to content

Commit

Permalink
Add hide content in 3DComponent (#3853)
Browse files Browse the repository at this point in the history
* Add hide content

* Fix bot comments
  • Loading branch information
Samuelopez-ansys authored Nov 7, 2023
1 parent d9fd4fa commit 4abc8f5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions _unittest/test_08_Primitives3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,13 @@ def test_64_create_3d_component_encrypted(self):
is_encrypted=True,
password="password_test",
)
assert self.aedtapp.modeler.create_3dcomponent(
self.component3d_file,
included_cs="Global",
is_encrypted=True,
password="password_test",
hide_contents=["Solid"],
)
assert not self.aedtapp.modeler.create_3dcomponent(
self.component3d_file,
included_cs="Global",
Expand Down
14 changes: 10 additions & 4 deletions pyaedt/modeler/modeler3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ def create_3dcomponent(
password_type : str, optional
Password type. Options are ``UserSuppliedPassword`` and ``InternalPassword``.
The default is ``UserSuppliedPassword``.
hide_contents : bool, optional
Whether to hide contents. The default is ``False``.
hide_contents : bool or list, optional
List of object names to hide when the component is encrypted.
If set to an empty list or ``False``, all objects are visible.
replace_names : bool, optional
Whether to replace objects and material names.
The default is ``False``.
Expand Down Expand Up @@ -161,6 +162,7 @@ def create_3dcomponent(
return False
if component_outline not in ["BoundingBox", "None"]:
return False
hide_contents_flag = is_encrypted and isinstance(hide_contents, list)
arg = [
"NAME:CreateData",
"ComponentName:=",
Expand Down Expand Up @@ -200,7 +202,7 @@ def create_3dcomponent(
"PasswordType:=",
password_type,
"HideContents:=",
hide_contents,
hide_contents_flag,
"ReplaceNames:=",
replace_names,
"ComponentOutline:=",
Expand All @@ -220,7 +222,11 @@ def create_3dcomponent(
if "CreateRegion:1" in self.oeditor.GetChildObject(el).GetChildNames():
objs.remove(el)
arg.append("IncludedParts:="), arg.append(objs)
arg.append("HiddenParts:="), arg.append([])
arg.append("HiddenParts:=")
if not hide_contents_flag:
arg.append([])
else:
arg.append(hide_contents)
if included_cs:
allcs = included_cs
else:
Expand Down

0 comments on commit 4abc8f5

Please sign in to comment.