Skip to content

Commit

Permalink
Merge branch 'release/v0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Zepmanbc committed Oct 12, 2019
2 parents 833838f + 948ba5e commit 45c4034
Show file tree
Hide file tree
Showing 15 changed files with 244 additions and 23 deletions.
22 changes: 22 additions & 0 deletions HISTORY.rst
Expand Up @@ -2,6 +2,28 @@
History
=======

0.4.0 (2019-10-12)
------------------

* Update for `Creoson 2.5.0 release`_.
* New functions:
* file_delete_material
* drawing_get_sheet_format
* dimension_set_text
* Add parameters:
* windchill_clear_workspace: filenames
* dimension_list: select
* dimension_list_detail: select
* feature_resume: `name` can be an integer for *feat_ID*
* feature_suppress: `name` can be an integer for *feat_ID*
* New returns:
* note_get: location
* dimension_list: dwg_dim
* dimension_list_detail: dwg_dim
* Few notes updates

.. _`Creoson 2.5.0 release`: https://github.com/SimplifiedLogic/creoson/releases/tag/v2.5.0

0.3.3 (2019-07-13)
------------------

Expand Down
8 changes: 7 additions & 1 deletion creopyson/__init__.py
Expand Up @@ -4,7 +4,7 @@

__author__ = """Benjamin C."""
__email__ = 'zepman@gmail.com'
__version__ = '0.3.3'
__version__ = '0.4.0'

from creopyson.connection import Client
from creopyson.objects import jlpoint
Expand Down Expand Up @@ -47,12 +47,14 @@
from creopyson.dimension import list_detail as dimension_list_detail
from creopyson.dimension import list_ as dimension_list
from creopyson.dimension import set_ as dimension_set
from creopyson.dimension import set_text as dimension_set_text
from creopyson.dimension import show as dimension_show
from creopyson.dimension import user_select as dimension_user_select
Client.dimension_copy = dimension_copy
Client.dimension_list_detail = dimension_list_detail
Client.dimension_list = dimension_list
Client.dimension_set = dimension_set
Client.dimension_set_text = dimension_set_text
Client.dimension_show = dimension_show
Client.dimension_user_select = dimension_user_select

Expand All @@ -72,6 +74,7 @@
from creopyson.drawing import get_cur_model as drawing_get_cur_model
from creopyson.drawing import get_cur_sheet as drawing_get_cur_sheet
from creopyson.drawing import get_num_sheets as drawing_get_num_sheets
from creopyson.drawing import get_sheet_format as drawing_get_sheet_format
from creopyson.drawing import get_sheet_scale as drawing_get_sheet_scale
from creopyson.drawing import get_sheet_size as drawing_get_sheet_size
from creopyson.drawing import get_view_loc as drawing_get_view_loc
Expand Down Expand Up @@ -107,6 +110,7 @@
Client.drawing_get_cur_model = drawing_get_cur_model
Client.drawing_get_cur_sheet = drawing_get_cur_sheet
Client.drawing_get_num_sheets = drawing_get_num_sheets
Client.drawing_get_sheet_format = drawing_get_sheet_format
Client.drawing_get_sheet_scale = drawing_get_sheet_scale
Client.drawing_get_sheet_size = drawing_get_sheet_size
Client.drawing_get_view_loc = drawing_get_view_loc
Expand Down Expand Up @@ -192,6 +196,7 @@
from creopyson.file import backup as file_backup
from creopyson.file import close_window as file_close_window
from creopyson.file import display as file_display
from creopyson.file import delete_material as file_delete_material
from creopyson.file import erase as file_erase
from creopyson.file import erase_not_displayed as file_erase_not_displayed
from creopyson.file import exists as file_exists
Expand Down Expand Up @@ -225,6 +230,7 @@
Client.file_backup = file_backup
Client.file_close_window = file_close_window
Client.file_display = file_display
Client.file_delete_material = file_delete_material
Client.file_erase = file_erase
Client.file_erase_not_displayed = file_erase_not_displayed
Client.file_exists = file_exists
Expand Down
72 changes: 69 additions & 3 deletions creopyson/dimension.py
Expand Up @@ -40,10 +40,14 @@ def list_(
name=None,
file_=None,
dim_type=None,
encoded=None
encoded=None,
select=False
):
"""Get a list of dimensions from a model.
If select is true, then the current selection in Creo will be cleared even
if no items are found.
Args:
client (obj):
creopyson Client.
Expand All @@ -57,6 +61,9 @@ def list_(
Valid values: linear, radial, diameter, angular.
encoded (boolean, optional):
Whether to return the values Base64-encoded. Defaults is False.
select (boolean, optional):
If true, the dimensions that are found will be selected in Creo.
Defaults is False.
Returns:
(list:dict): List of dimension information.
Expand All @@ -67,6 +74,9 @@ def list_(
if encoded is False it is a float.
encoded (boolean):
Whether the returned value is Base64-encoded.
dwg_dim (boolean):
Whether dimension is a drawing dimension rather than
a model dimension.
"""
data = {}
Expand All @@ -85,6 +95,8 @@ def list_(
data["dim_type"] = dim_type
if encoded:
data["encoded"] = encoded
if select:
data["select"] = select
return client._creoson_post("dimension", "list", data, "dimlist")


Expand All @@ -93,10 +105,16 @@ def list_detail(
name=None,
file_=None,
dim_type=None,
encoded=None
encoded=None,
select=False
):
"""Get a list of dimension details from a model.
Values will automatically be returned Base64-encoded if they are strings
which contain Creo Symbols or other non-ASCII data.
If select is true, then the current selection in Creo will be cleared
even if no items are found.
Args:
client (obj):
creopyson Client.
Expand All @@ -110,6 +128,9 @@ def list_detail(
Valid values: linear, radial, diameter, angular.
encoded (boolean, optional):
Whether to return the values Base64-encoded. Defaults is False.
select (boolean, optional):
If true, the dimensions that are found will be selected in Creo.
Defaults is False.
Returns:
(list:dict): List of dimension information.
Expand All @@ -127,6 +148,9 @@ def list_detail(
dim_type (str):
Dimension type.
Valid values: linear, radial, diameter, angular.
dwg_dim (boolean):
Whether dimension is a drawing dimension rather than
a model dimension.
text (str):
dimension text.
location (dict): Coordonates location.
Expand Down Expand Up @@ -160,11 +184,19 @@ def list_detail(
data["dim_type"] = dim_type
if encoded:
data["encoded"] = encoded
if select:
data["select"] = select
return client._creoson_post("dimension", "list_detail", data, "dimlist")


def set_(client, name, value, file_=None, encoded=None):
"""Set a dimension value.
r"""Set a dimension value.
One reason to encode values is if the value contains special characters,
such as Creo symbols.
You may be able to avoid Base64-encoding symbols by using Unicode for the
binary characters, for example including \\u0001#\\u0002 in the value to
insert a plus/minus symbol.
Args:
client (obj):
Expand Down Expand Up @@ -202,6 +234,40 @@ def set_(client, name, value, file_=None, encoded=None):
return client._creoson_post("dimension", "set", data)


def set_text(client, name, file_=None, text=None, encoded=False):
"""Set dimension text.
Args:
client (obj):
creopyson object.
name (str):
Dimension name.
`file_` (string, optional):
file name, if not set, active model is used.
text ([type], optional):
Dimension text. Defaults to None, sets the dimension's text to @D.
encoded (bool, optional):
Whether the text value is Base64-encoded. Defaults to False.
Returns:
None
"""
data = {
"name": name,
"encoded": encoded,
}
if file_ is not None:
data["file"] = file_
else:
active_file = client.file_get_active()
if active_file is not None:
data["file"] = active_file["file"]
if text:
data["text"] = text
return client._creoson_post("dimension", "set_text", data)


def show(client, name, file_=None, assembly=None, path=None):
"""Display or hide a dimension in Creo.
Expand Down
27 changes: 27 additions & 0 deletions creopyson/drawing.py
Expand Up @@ -454,6 +454,33 @@ def get_num_sheets(client, drawing=None):
"drawing", "get_num_sheets", data, "num_sheets")


def get_sheet_format(client, sheet, drawing=None):
"""Get the drawing format file of drawing sheet.
Args:
client (obj):
creopyson Client.
sheet (int):
Sheet number.
drawing (str, optional):
Drawing name. Defaults: current active drawing.
Returns:
(dict):
file(str):
Format file name, may be null if there is no current format.
full_name(str):
Format full name.
common_name(str):
Format common name.
"""
data = {"sheet": sheet}
if drawing:
data["drawing"] = drawing
return client._creoson_post("drawing", "get_sheet_format", data)


def get_sheet_scale(client, sheet, drawing=None, model=None):
"""Get the scale of a drawing sheet.
Expand Down
22 changes: 16 additions & 6 deletions creopyson/feature.py
Expand Up @@ -436,9 +436,12 @@ def resume(
`file_` (str, optional):
File name (wildcards allowed: True).
Defaults is the currently active model.
name (str|list:str, optional):
Feature name, (wildcards allowed: True);
name (int|str|list:str, optional):
Feature name or Feature ID, (wildcards allowed: True);
if empty then all features are resumed.
int => Feat_ID
str => name
list:str => names
status (str, optional):
Feature status pattern. Defaults: All feature statuses.
Valid values: ACTIVE, INACTIVE, FAMILY_TABLE_SUPPRESSED,
Expand All @@ -464,7 +467,9 @@ def resume(
if active_file is not None:
data["file"] = active_file["file"]
if name:
if isinstance(name, (str)):
if isinstance(name, (int)):
data["feat_id"] = name
elif isinstance(name, (str)):
data["name"] = name
elif isinstance(name, (list)):
data["names"] = name
Expand Down Expand Up @@ -563,9 +568,12 @@ def suppress(
`file_` (str, optional):
File name (wildcards allowed: True).
Defaults is the currently active model.
name (str|list:str, optional):
Dimension name, (wildcards allowed: True);
name (int|str|list:str, optional):
Feature name or Feature ID, (wildcards allowed: True);
if empty then all features are suppressed.
int => Feat_ID
str => name
list:str => names
status (str, optional):
Feature status pattern. Defaults: All feature statuses.
Valid values: ACTIVE, INACTIVE, FAMILY_TABLE_SUPPRESSED,
Expand Down Expand Up @@ -595,7 +603,9 @@ def suppress(
if active_file is not None:
data["file"] = active_file["file"]
if name:
if isinstance(name, (str)):
if isinstance(name, (int)):
data["feat_id"] = name
elif isinstance(name, (str)):
data["name"] = name
elif isinstance(name, (list)):
data["names"] = name
Expand Down
23 changes: 23 additions & 0 deletions creopyson/file.py
Expand Up @@ -148,6 +148,29 @@ def close_window(client, file_=None):
return client._creoson_post("file", "close_window", data)


def delete_material(client, material, file_=None):
"""Delete a material from a part.
Args:
client (obj):
creopyson object
material (str):
Material name
`file_` (str, optional):
File name. Defaults is currently active model.
"""
data = {
"material": material,
}
if file_ is not None:
data["file"] = file_
else:
active_file = client.file_get_active()
if active_file is not None:
data["file"] = active_file["file"]
return client._creoson_post("file", "delete_material", data)


def display(client, file_, activate=None):
"""Display a model in a window.
Expand Down

0 comments on commit 45c4034

Please sign in to comment.