Skip to content

Commit 94bedf6

Browse files
committed
Merge branch 'developement'
2 parents 7823598 + aa97921 commit 94bedf6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+209
-394
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ quick_n_dirty.py
135135
*.CATDrawing
136136
*.CATPart
137137
*.CATProduct
138+
*.CATMaterial
138139

139140
pycatia-exe.build
140141
pycatia-exe.dist

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
# Changelog
22

33
## 0.7.1
4+
45
* fixed Documents.read() method which was broken by changes made in 0.6.9.
6+
* updated Documents.open() so that filename should now be a Path object.
7+
* updated Documents.new_from() so that filename should now be a Path object.
8+
* updated Documents.open() so that filename should now be a Path object.
9+
* updated the examples so they use explicit path objects.
10+
* updated the examples to show how to better initialise documents.
11+
* updated the user_scripts to show how to better initialise documents.
12+
* updated the introdutcion document to show how to get the PartDocument.
13+
514

615
## 0.7.0
716
* fixed the following Class methods so that the Reference.com_object is passed to

docs/introduction.rst

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ You will almost always want to import the `catia`
1919
.. code-block:: python
2020
2121
from pycatia import catia
22+
from pycatia.mec_mod_interfaces.part_document import PartDocument
2223
# initialise the catia automation appliction. CATIA V5 should already be running.
2324
caa = catia()
2425
documents = caa.documents
@@ -28,27 +29,20 @@ class.
2829

2930
.. code-block:: python
3031
31-
documents.add('Part')
32+
part_document: PartDocument = documents.add('Part')
3233
3334
the add method of the documents class expects the string 'Part', 'Product' or
3435
'Drawing'. ``documents.add('Part')`` adds a new CATPart to the documents
35-
collection.
36-
37-
We want to work on this new document. Since this has just been added it's the
38-
active document.
39-
40-
.. code-block:: python
41-
42-
document = caa.active_document
36+
collection and returns a `Document`` object. In this case it is a `PartDocument`.
4337

4438
The document object :ref:`Document<Document>` has a
4539
number of properties that can be accessed.
4640

4741
.. code-block:: python
4842
49-
document.name
43+
part_document.name
5044
# returns the name of the new document.
51-
document.path
45+
part_document.path
5246
# returns the pathlib.Path object of the document.
5347
5448
@@ -61,7 +55,7 @@ create one here anyway.
6155

6256
.. code-block:: python
6357
64-
part = document.part()
58+
part = part_document.part
6559
hybrid_bodies = part.hybrid_bodies
6660
new_set = hybrid_bodies.add()
6761
new_set.name
@@ -71,7 +65,6 @@ create one here anyway.
7165
7266
7367
74-
7568
For more detailed examples on how to interact with pycatia see the
7669
:ref:`examples` page. There contain several scripts that can be run in the
7770
terminal.

examples/example__assembly_convertor__001.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,14 @@
3333

3434
from pycatia import catia
3535
from pycatia.product_structure_interfaces.assembly_convertor import AssemblyConvertor
36-
from pycatia.product_structure_interfaces.product import Product
3736
from pycatia.product_structure_interfaces.product_document import ProductDocument
3837

3938
# file_type can be "TXT", "HTML" or "XLS".
4039
file_type = "XLS"
4140

4241
caa = catia()
43-
document = ProductDocument(caa.active_document.com_object)
44-
product = Product(document.product.com_object)
45-
# Note: It's not necessary to explicitly use the ProductDocument or the Product class
46-
# with the com_object. It's perfectly fine to write it like this:
47-
# document = caa.active_document
48-
# product = document.product
49-
# But declaring 'document' and 'product' this way, your linter can't resolve the
50-
# product reference, see https://github.com/evereux/pycatia/issues/107#issuecomment-1336195688
42+
product_document = ProductDocument(caa.active_document.com_object)
43+
product = product_document.product
5144

5245
bom = product.get_item("BillOfMaterial")
5346
assembly_convertor = AssemblyConvertor(bom.com_object)

examples/example__bom_custom_001.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,12 @@
2525
from datetime import datetime
2626

2727
from pycatia import catia
28-
from pycatia.product_structure_interfaces.product import Product
2928
from pycatia.product_structure_interfaces.product_document import ProductDocument
3029

3130
caa = catia()
32-
document = ProductDocument(caa.active_document.com_object).product
33-
product = Product(document.com_object)
31+
product_document: ProductDocument = caa.active_document
32+
product = product_document.product
3433
products = product.products
35-
# Note: It's not necessary to explicitly use the ProductDocument or the Product class
36-
# with the com_object. It's perfectly fine to write it like this:
37-
# document = caa.active_document
38-
# product = document.product
39-
# But declaring 'document' and 'product' this way, your linter can't resolve the
40-
# product reference, see https://github.com/evereux/pycatia/issues/107#issuecomment-1336195688
4134

4235
part_numbers = []
4336
prd_dict = {}

examples/example__constraints_001.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,12 @@
2424

2525
from pycatia import catia
2626
from pycatia.enumeration.enumeration_types import cat_constraint_type
27-
from pycatia.product_structure_interfaces.product import Product
2827
from pycatia.product_structure_interfaces.product_document import ProductDocument
2928

3029
caa = catia()
31-
document = ProductDocument(caa.active_document.com_object).product
32-
product = Product(document.com_object)
33-
# Note: It's not necessary to explicitly use the ProductDocument or the Product class
34-
# with the com_object. It's perfectly fine to write it like this:
35-
# document = caa.active_document
36-
# product = document.product
37-
# But declaring 'document' and 'product' this way, your linter can't resolve the
38-
# product reference, see https://github.com/evereux/pycatia/issues/107#issuecomment-1336195688
30+
# if the active document is a CATProduct this will return a ProductDocument
31+
product_document: ProductDocument = caa.active_document
32+
product = product_document.product
3933

4034
products = product.products
4135
constraints = product.constraints()

examples/example__document__001.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222
sys.path.insert(0, os.path.abspath("..\\pycatia"))
2323
##########################################################
24-
24+
from pathlib import Path
2525
import time
2626

2727
from pycatia import CATIADocHandler
2828

29-
catia_part = r"tests\cat_files\part_measurable.CATPart"
29+
catia_part = Path(os.getcwd(), r"tests\cat_files\part_measurable.CATPart")
3030

3131
with CATIADocHandler(catia_part) as caa:
3232
document = caa.document

examples/example__document__003.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,26 @@
2626
from pathlib import Path
2727

2828
from pycatia import catia
29-
from pycatia.in_interfaces.document import Document
29+
from pycatia.mec_mod_interfaces.part_document import PartDocument
3030

3131
# path to file to open.
32-
file_name = r"tests\cat_files\part_measurable.CATPart"
32+
file_name = Path(os.getcwd(), r"tests\cat_files\part_measurable.CATPart")
3333

3434
caa = catia()
3535
# open document
3636
documents = caa.documents
37-
documents.open(file_name)
37+
part_document: PartDocument = documents.open(file_name)
3838

39-
document = caa.active_document
40-
assert isinstance(document, Document)
39+
assert isinstance(part_document, PartDocument)
4140

4241
# _Full_ path of new file. This uses current working directory.
4342
new_file_name = Path(os.getcwd(), "new_part.CATPart")
4443
# save document as new name.
45-
document.save_as(new_file_name, overwrite=True)
44+
part_document.save_as(new_file_name, overwrite=True)
4645

4746
# to export to another support file_format (license permitting).
4847
new_export_file_name = Path("c:\\temp\\new_export_part.stp")
49-
document.export_data(new_export_file_name, "stp", overwrite=True)
48+
part_document.export_data(new_export_file_name, "stp", overwrite=True)
5049

5150
# close document
52-
document.close()
51+
part_document.close()

examples/example__drafting__001.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,9 @@
3636
a0_y = 841
3737

3838
caa = catia()
39-
document = DrawingDocument(caa.active_document.com_object)
40-
drawing = DrawingRoot(document.drawing_root.com_object)
41-
# Note: It's not necessary to explicitly use the DrawingDocument or the DrawingRoot class
42-
# with the com_object. It's perfectly fine to write it like this:
43-
# document = caa.active_document
44-
# drawing = document.drawing_root
45-
# But declaring 'document' and 'drawing_root' this way, your linter can't resolve the
46-
# product reference, see https://github.com/evereux/pycatia/issues/107#issuecomment-1336195688
39+
# if the active document is a CATDrawing this will return a DrawingDocument
40+
drawing_document: DrawingDocument = caa.active_document
41+
drawing = DrawingRoot(drawing_document.drawing_root.com_object)
4742

4843
sheets = drawing.sheets
4944
sheet = sheets.active_sheet

examples/example__human_modelling__001.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,13 @@
2222
from pycatia import catia
2323
from pycatia.enumeration.enumeration_types import swk_anthro_sex
2424
from pycatia.enumeration.enumeration_types import swk_posture_spec
25-
from pycatia.product_structure_interfaces.product import Product
2625
from pycatia.product_structure_interfaces.product_document import ProductDocument
2726
from pycatia.dnb_human_modeling_interfaces.swk_hmi_workbench import SWKHmiWorkbench
2827

2928
caa = catia()
30-
document = ProductDocument(caa.active_document.com_object)
31-
product = Product(document.product.com_object)
32-
# Note: It's not necessary to explicitly use the ProductDocument or the Product class
33-
# with the com_object. It's perfectly fine to write it like this:
34-
# document = caa.active_document
35-
# product = document.product
36-
# But declaring 'document' and 'product' this way, your linter can't resolve the
37-
# product reference, see https://github.com/evereux/pycatia/issues/107#issuecomment-1336195688
38-
29+
# if the active document is a CATProduct this will return a ProductDocument
30+
product_document: ProductDocument = caa.active_document
31+
product = product_document.product
3932

4033
human_work_bench = SWKHmiWorkbench(product.get_technological_object("HumanWorkbench"))
4134
gender = swk_anthro_sex.index("Female")

0 commit comments

Comments
 (0)