Git Product home page Git Product logo

pycatia's Introduction

pycatia

alpha software

This is alpha software.

All the test cases and examples work but there will be many issues outside of the test framework. The CATIA com interface is large and I've predominantly wrote tests for those areas I'm familiar. Any bugs that exist should be for the most part be quite easy to fix using those methods that do work as a reference.

I have limited access to CATIA licences / workbenches. Also, there are many modules that I simply don't know what they do. Thus my ability to test and support can be limited.

Any bugs that exist should be for the most part be quite easy to fix using those methods that do work as a reference.

Requirements

  • python >= 3.9
  • CATIA V5 running on Windows.
  • see requirements.txt

Installation

see installation.

Usage

See the introduction, examples and user_scripts for a good over view on how to use pycatia.

Links

Releases: pycatia @ pypi.org

Examples And Scripts

See the documentation @ examples and user_scripts.

A GUI based application that uses pycatia - pycatia-tools.

Asking Questions

Please read the following with regards to raising questions: #28

Contributing

See CONTRIBUTING.md in root of github repository.

Running The Tests

Prior to running the tests please ensure CATIA V5 has the following configuration settings:

  • CGR cache system must be disabled.
  • Do not activate default shapes on open must be disabled.
  • Parameter names must not have back ticks enabled. Tools > Options > General > Parameters and Measure > Knowledge > Parameter Names > Surrounded by the ` symbol.

On the first run, during the running of the tests, the test suite will create the CATIA drawing, products and part it requires to run in the folder tests/cat_files.

CATIA V5 should already be running and have NO documents already open.

To run the tests with coverage (-v is verbosity):

py.test -v --cov-report term-missing --cov=pycatia

To run a specific test:

py.test -v tests/test_product.py::test_move

To stop tests running after first failure.

py.test -vx

Release process

A reminder for @evereux. I don't do this often and forget ...

  • Check version is correct.
  • Check changelog has been updated.
  • Run the tests. pytest -v tests
    • Ensure cache is disabled and
    • Fix any issues.
  • Run the examples.
    • Fix any issues.
  • Build the docs. cd docs ./make html
    • Fix any issues.
  • Run mypy over module. mypy pycatia
  • Build source. python setup.py sdist bdist_wheel
    • Check source contents.
  • Build pycatia exe python -m nuitka --standalone pycatia-exe.py. * use 64 env. * rename pycatia-exe.exe. * copy build to win_32 folder and zip.
  • Merge changes with master branch and upload.
  • Upload to pypi. twine upload dist/*.
  • Update github releases.

pycatia's People

Contributors

carrotc avatar deloarts avatar evereux avatar hitman061 avatar luanee avatar marciolrc avatar mithro86 avatar mokrueger avatar ptm-tm avatar tian-jionglu avatar z86961027 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pycatia's Issues

select_element2 and select_element3 object error

Hi,
when i am using select_element2 and select_element3 object in pycatia i am getting error like below mentioned.
TypeError: Objects for SAFEARRAYS must be sequences (of sequences), or a buffer object
any help is appreciated.
i hope this time , i have formatted the code, if it is not showing formatted please let me know.

my code pasted below:

from pycatia import catia documents = catia.documents rootProduct = 0 try: documents1 = catia.active_document rootProduct = documents1.product() except: print ("Product is not open") sys.exit() else: print("Product Documnet found") Object_Filter = ("Product") catia.active_document.selection.clear selectionSet = catia.active_document.selection status = selectionSet.select_element2(Object_Filter , "Select Product" , True) #status = selectionSet.select_element3(Object_Filter ,"Select Product" , True , 1 , True)

Error
`Traceback (most recent call last):

File "", line 1, in
runfile('C:/Users/A337885/Desktop/PY/untitled1.py', wdir='C:/Users/A337885/Desktop/PY')

File "C:\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)

File "C:\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/A337885/Desktop/PY/untitled1.py", line 17, in
status = selectionSet.select_element2(Object_Filter , "Select Product" , True)

File "C:\Anaconda3\lib\site-packages\pycatia\in_interfaces\selection.py", line 1623, in select_element2
i_object_selection_before_command_use_possibility)

File "<COMObject >", line 4, in SelectElement2

TypeError: Objects for SAFEARRAYS must be sequences (of sequences), or a buffer object.`

Generate CATPart From Product

is it possible to do Generate CATPart From Product in python code?
if it is possible, can anyone share some snippet of that code?

How do i "New/CATPart"

Hi,

Just started tinkering with this library but did not seem to find a way to get an CATPart/ CATProduct to open as New...is that possible currently? I'm using Catia V5R20 & Python 3.7 on Windows10. Thanks.

How to get the user defined properties in part or product?

How to get the user defined properties in part or product?

i am trying with "user_ref_properties", its throwing me a com error like below.

com_error: (-2147352567, 'Exception occurred.', (0, 'CATIAProduct', 'The method UserRefProperties failed', None, 0, -2147467259), None)

Can any one help me in that?

Originally posted by @tcrakshi in #10 (comment)

How can i show the *.CATPat files use this module

There is no examples that use the module to show the *.CATPat files.

May i ask for some advice that how i can use the pycatia to show my *.CATPat file, through vtk or something else, thank you!

Installation failed

hi
I followed the installation instructions and an error occurred at the last step.
What is the cause.
image

how to load?

Hello

There are 3drep files in my 3DXML file.

How should this file be loaded.

image

Add type annotations to methods while scraping .chm help file

Hi, your package looks great! I had an enhancement suggestion which is to add type hints to the class methods generated which scraping the original .chm help files.

If you share your script used to scrape .chm files or add it to the repository (I couldn't find it, sorry), I'm happy to help out. It would be much easier than me trying to manually add them all in.

Thanks!

any object to specific object in selection

Hi,
my requirement is to apply the design mode only for selected object.

Error:
AttributeError: 'AnyObject' object has no attribute 'apply_work_mode'

Can i get help regarding this?

My Code:

from pycatia import catia  
documents = catia.active_document
rootProduct = 0
try:
    rootProduct = documents.product()
except:
    print ("Product is not open")
    sys.exit()
else:
    print("Product Documnet found")

ProductSelection = []
object_filter = ("Product",)
selectionSet = catia.active_document.selection
status = selectionSet.select_element3(object_filter,"Select Product" , False , 2 , False)
if status == "Normal":
    selectionCount =  catia.active_document.selection.count
    selected_product = documents.product()
    for i in range(0 , selectionCount):
        selected_product = catia.active_document.selection.item(i+1).value
        ProductSelection.append(selected_product)
        
    catia.active_document.selection.clear()      
    for i in range(0 , len(ProductSelection)):
        ## For each selected product need to apply design Mode
        product = ProductSelection[i]
        product.apply_work_mode(cat_work_mode_type.index("DESIGN_MODE"))

error with Traceback

Traceback (most recent call last):

  File "<ipython-input-33-60de4e074a48>", line 1, in <module>
    runfile('C:/Users/A337885/Desktop/PY/untitled1.py', wdir='C:/Users/A337885/Desktop/PY')

  File "C:\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "C:\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/A337885/Desktop/PY/untitled1.py", line 27, in <module>
    product.apply_work_mode(cat_work_mode_type.index("DESIGN_MODE"))

AttributeError: 'AnyObject' object has no attribute 'apply_work_mode'

How to execute python script without python installed?

How to call the python code in catia?
if catia user dont have python editor in his machine, how it will work?
is there any mechanism to tackles this issue?

because native catia user dont have background of coding , so how we can deploy too the user to launch the python code in Catia interface. (Like catia native commands)

Regards,
Rakshith

Improve the behavior of broken links [FEATURE REQUEST]

Suppose that we opened a root product, which has 5 sub products. And one of the sub product's link is broken.
Then we try the script below:

from pycatia import catia

caa = catia()
document = caa.active_document
product = document.product()
products = product.products
for sub_prd in products:
    print(sub_prd.file_name)

An com_error will occur when the process meet the broken link.
I think it's better to raise a "BrokenLinkErr" here. It would be more friendly for programmer to debug. (It take me a lot of time to find out this error when looping in a huge tree)

Or, if there is better solution to solve broken link problems, it is appreciated.

3D space between 2 part

Hi,
By using python in Catia, is it possible to identify Space between given two volumes.

[BUG]`file_name` argument in methods

Describe the bug
It's a bug found in my application with pycatia, to create TIFF drawing from CATDrawing.
https://github.com/Tian-Jionglu/pycatia/projects/1#card-47338604

To Reproduce

from pycatia import catia

caa = catia()
drawing_doc = caa.active_document

# dir "F:/temp/output/" is existed, dir "F:/output/" is not. "test.CATDrawing" is the active_document

# case1
drawing_doc.export_data("F:/temp/output/", "tif", overwrite=True)
    # expect to get file "F:/temp/output/test.tif". Result is com_error.

# case2
drawing_doc.export_data("F:/temp/output", "tif", overwrite=True)
    # expect to get file "F:/temp/output/test.tif". Get file "F:/temp/output.tif" as a result.

# case3
drawing_doc.export_data(f"F:/temp/output/{drawing_doc.name}", "tif", overwrite=True)
    # expect to get file "F:/temp/output/test.tif". Result is nothing

# case4
drawing_doc.export_data("F:/temp/output/test.tif", "tif", overwrite=True)
    # expect to get file "F:/temp/output/test.tif". Result is as expected.

# case5
drawing_doc.export_data("F:/temp/output/test", "tif", overwrite=True)
    # expect to get file "F:/temp/output/test.tif". Result is as expected.

# case6
drawing_doc.export_data("F:/temp/output/test.name", "tif", overwrite=True)
    # expect to get file "F:/temp/output/test.name.tif". Result is nothing.(".name" is unknown suffix, sometimes users type tihs by fault)

# case7
drawing_doc.export_data("F:/output/test", "tif", overwrite=True)
    # expect an error to remind the directory is not exist. Result is com_error

Expected behavior
see notations.

Desktop (please complete the following information):

  • OS: Windows 10
  • CATIA V5 version: V5-R19
  • pycatia version: pycatia merged #60

Additional context
It's a similar bug as in #58 .
Type str or Path, the file_name argument should be?
I think the type can be uniformed in methods below:

  • docuemnt.export_data
  • document.save_as
  • sheet.print_to_file
  • maybe there is more...

Installation Error

When trying to install pycatia step by step with the installation guide, I had the following Error: ERROR: Could not install packages due to an EnvironmentError: No such file or directory: 'C:\...\AppData\Local\Temp\pip-install-mldm2ljt\pycatia\pycatia-0.1.4.dist-info\WHEEL'

I tried it with two versions of python, which where the latest python version of v3.7.3 and version 3.6.8 with the same result.

Is there anything I can do to resolve this issue?

Greets, Oliver

It's better to set 'Application.display_file_alters = False' when set 'overwrite=True' in document.save_to' method

Hi,
here is a script I wrote to use in production.

Task:

To change all the CATDrawings in a specific project. The client wants to change former company logo in border frame into new company name. The former logo is drawn with Polylines and filled with Area Fill. The border frame is placed in first detail view in the first detail sheet. All drawings is A0 frame and plus.

Environment:

  • Windows OS version: 10
  • CATIA version: V5 R19
  • Python version: 3.8.3
  • pycatia version: 0.4.0

code:

import os
import glob
from pycatia import CATIADocHandler
from pycatia import catia

# set display_file_alerts = False, to avoid confirming overwrite
caa = catia()
caa.display_file_alerts = False

# get all the CATDrawings in the input 
directory = r'my directory'
file_pattern = os.path.join(directory, 'input', '*.CATDrawing')
files = glob.glob(file_pattern)

for file in files:
    with CATIADocHandler(file) as caa:
        # get the document, sheet and view object that would be used
        document = caa.document
        drawing = document.drawing_root()
        sheets = drawing.sheets
        sheet = sheets[1]
        views = sheet.views
        view = views[2]

        # since I can't find method to get polyline objects, I tried search method to get them and delete
        sel = document.selection
        sel.clear
        sel.add(view)
        sel.search("Drafting.Area Fill, sel")
        try:
            sel.delete()
        except:
            pass

        sel.clear
        sel.add(view)
        sel.search("Drafting.Polyline, sel")
        try:
            sel.delete()
        except:
            pass
        
        # add the new company name
        texts = view.texts
        text = texts.add('New Company Name', 20, 841/2)
        text.anchor_position = 6
        text.angle = 90
        text.name = 'Text_Corporation_Name'
        text.text_properties.font_size = 10
        text.set_font_name = 'Arial'
        sheet.force_update()

        new_file = os.path.join(directory, 'output', document.name)
        document.save_as(new_file, overwrite=True)

When debugging the code, the output directory was filled with some files. I have to click OK for each file to overwrite it. It's annoying.
When overwrite=True is set, I think the user already knows what would happen then. It would be better to set Application.display_file_alters = False than raise a warning to remind "Click OK" in command window.

Besides, I can't find a proper method to get the 2DPolyline object in CATDrawing. Anyone has good idea?

[SUPPORT REQUEST] Activate terminal node method.

on example 11 about acvivate terminal node,
I found some problem
or I am not sure this code is working properly.

because my product catia file size is too heavy, I usually use 'Do not activate default shape' option.

When I load product data first,
any product(cgr) data can't be seen,

even though loading is sucessful and there's no error in your example code.

In this condition(my option set up),
I really want to know how to activate terminal node after loading data by using python.

  • my product consist of all cgr file(no parts)

[example11 in code]
from pycatia import catia from pycatia.enumeration.enumeration_types import cat_work_mode_type from pycatia.product_structure_interfaces.product import Product caa = catia() documents = caa.documents documents.open(r'D:\CATIA\test.CATProduct') document = caa.active_document product = document.product() product.apply_work_mode(cat_work_mode_type.index("DESIGN_MODE")) Product.activate_terminal_node(product.get_products())

Change product position

Hi,
i want change the position of product, i have all the 12 component.
Can any one provide me some snippet of "set_components" method.

How to take screenshots from different directions

For documentation purpose I want to take screenshots from different directions. The screenshot itself is already working. Where I got stuck is the rotation of my viewpoint.

from pycatia import catia
import pycatia.in_interfaces.viewpoint_3d as vp3d

caa = catia()
caa.documents.open('dummy.CATPart')

# create screenshot from iso view
caa.active_window.active_viewer.reframe()
caa.active_window.active_viewer.zoom_in()
caa.active_window.active_viewer.capture_to_file(5, 'iso.jpeg')

# create screenshot from x view
x_up = [1,0,0]
cur_vp3d = vp3d.Viewpoint3D(caa.active_window.active_viewer.com_object)
cur_vp3d.put_sight_direction(x_up)
caa.active_window.active_viewer.reframe()
caa.active_window.active_viewer.zoom_in()
caa.active_window.active_viewer.capture_to_file(5, 'x_up.jpeg')

Thank you

Obtain Bounding Box from components in a Product

Hello,
I'm trying to obtain the Bounding Box of several ítems in a Product. The Bounding Box is available once is launched the 'Measure Inertia' inside CATIA, and clicking on Principal Axis in Customize options (see https://www.cadcam-group.eu/catia-v5-bounding-box). Once you have done this, it is easy to recover these parameters from the CATIA tree.
The problem is that I cannot automatize 'Measure Inertia', that is what measures and save the parameters in the tree.
I've seen you have some examples that obtain the CoG, mass, and some other parameters. Is it posible to do so to get these three parameter of the Bounding Box?
Thank you

Known Missing Methods

Thanks to a pull request from @Tian-Jionglu it came to my attention that the methods are missing from some pycatia classes.

The affected files are

ABQAutomationItf/abq_damper_connection_property.py 
ABQAutomationItf/abq_spring_connection_property.py 
* CATGSMIDLItf/hybrid_shape_curve_smooth.py 
DNBD5IInterfaces/import_d5_setting_att.py 
DNBDeviceInterfaces/dev_analysis_setting_att.py 
DNBRobotInterfaces/rob_analysis_setting_att.py 
DNBRobotInterfaces/rrs_setting_att.py 
DNBSimulationInterfaces/analysis_setting_att.py
DNBSimulationInterfaces/sim_trace_setting_att.py
DNBSimulationInterfaces/simulation_setting_att.py 
* DraftingInterfaces/drawing_thread.py 
FittingInterfaces/fitting_setting_att.py 
FittingInterfaces/manip_setting_att.py 
GenKnowledgeInterfaces/expert_check.py 
* InfInterfaces/application.py 
* InfInterfaces/selection.py 
KinematicsInterfaces/joint.py
* KnowledgeInterfaces/parameter.py
* NavigatorInterfaces/marker_setting_att.py
* SpaceAnalysisInterfaces/measurable.py
* SpaceAnalysisInterfaces/section.py
* SpaceAnalysisInterfacets/sections.py
* SpaceAnalysisInterfaces/spa_workbench.py
StructureInterfaces/str_feature_factory.py
StructureInterfaces/str_members.py
StructureInterfaces/str_object_factory.py
StructureInterfaces/str_plates.py
  • CATGSMIDLItf/hybrid_shape_curve_smooth.py
  • DraftingInterfaces/drawing_thread.py
  • InfInterfaces/application.py
  • InfInterfaces/selection.py
  • KnowledgeInterfaces/parameter.py
  • NavigatorInterfaces/marker_setting_att.py
  • SpaceAnalysisInterfaces/measurable.py
  • SpaceAnalysisInterfaces/section.py
  • SpaceAnalysisInterfacets/sections.py
  • SpaceAnalysisInterfaces/spa_workbench.py

Those methods can be found in the file v5automation-autogenerated.7z from the development branch.

Please note only those modules prefixed with an asterix have made it into pycatia.

I'll try and pick these off over the next few weeks but anyone is more than welcome to contribute and add the missing methods. If you're new to git and wish to try and create a pull request please feel free. You might mess up, that's ok, you won't break anything. 😄 👍

An example of what needs doing. Open the file SpaceAnalysisInterfaces/measurable.py from v5automation-autogenerated.7z and compare that with developement/pycatia/space_analyses_interfaces/measurable.py. You see the methods in the source aren't in the development branch.

AnalysisImage processing

After computing a Principal stress value with average Iso, I exported the data as a csv file but I only got the upper layer results.
How can I access the layer filter "Upper and Lower" in order to have both values in my csv file ?

Thank you very much

Raising Issues / Asking Questions.

Please don't raise an issue here until you have read the documentation, understood and met the requirements (YOU NEED CATIA INSTALLED) and have run the examples.

If you have upgraded from an earlier version and your script breaks please check the changelog as there will normally be information given for any breaking changes.

When raising an issue please give as much information as you can so I may try and reproduce the issue.

Please provide the following information:

  • Windows OS version.
  • CATIA version.
  • Python version.
  • pycatia version.
from pycatia import __version__
print(__version__)

Thanks! :-)

Add a warning to sheet.print_to_file [BUG]

Describe the bug
It seems that sheet.print_to_file method only works with absolute directory argument.

To Reproduce

from pycatia import catia

caa = catia()
drawing_doc = caa.active_document
sheets = drawing_rt.sheets
sheet = sheets[0]

sheet.print_to_file("./test.prn") # expected print to current directory
sheet.print_to_file("F:/temp/test.prn") # 'F:/temp/' exist.
sheet.print_to_file("F:/output/test.prn") # 'F:/output/' didn't exist. expected an error

Expected behavior
As a result, only second print_to_file (to 'F:/temp/') works as expected.
If this method performances the same in other environment, it's better to raise a warning, like "currently, this method only works with absolute directory argument. And this directory must already exist."

Desktop (please complete the following information):

  • OS: Windows 10
  • CATIA V5 R19
  • pycatia 0.4.3

how to call a macro

Hello everyone

i have written a python function that writes a macro file which works correctly.
Now I want to complete the function so that it calls the macro file too.
Could you please help me? Can pycatia do this?

def catcube(file_name, X, Y, Z):
    file_name = file_name
    x = "{:.6f}".format(X/2)
    y = "{:.6f}".format(Y/2)
    z = "{:.6f}".format(Z/2)

    import os
    import codecs
    import win32com.client
    import pycatia

    mcr = codecs.open(os.path.join(mcrlib, file_name+'.CATScript'), 'w', 'utf-8')
    mcr.write('Language="VBSCRIPT"\n\
\n\
Sub CATMain()\n\
\n\
Dim documents1 As Documents\n\
Set documents1 = CATIA.Documents\n\
\n\
Dim partDocument1 As Document\n\
Set partDocument1 = documents1.Add("Part")\n\
\n\
Dim part1 As Part\n\
Set part1 = partDocument1.Part\n\
\n\
Dim bodies1 As Bodies\n\
Set bodies1 = part1.Bodies\n\
\n\
Dim body1 As Body\n\
Set body1 = bodies1.Item("PartBody")\n\
\n\
Dim sketches1 As Sketches\n\
Set sketches1 = body1.Sketches\n\
\n\
Dim originElements1 As OriginElements\n\
Set originElements1 = part1.OriginElements\n\
\n\
Dim reference1 As AnyObject\n\
Set reference1 = originElements1.PlaneXY\n\
\n\
Dim sketch1 As Sketch\n\
Set sketch1 = sketches1.Add(reference1)\n\
\n\
Dim arrayOfVariantOfDouble1(8)\n\
arrayOfVariantOfDouble1(0) = 0.000000\n\
arrayOfVariantOfDouble1(1) = 0.000000\n\
arrayOfVariantOfDouble1(2) = 0.000000\n\
arrayOfVariantOfDouble1(3) = 1.000000\n\
arrayOfVariantOfDouble1(4) = 0.000000\n\
arrayOfVariantOfDouble1(5) = 0.000000\n\
arrayOfVariantOfDouble1(6) = 0.000000\n\
arrayOfVariantOfDouble1(7) = 1.000000\n\
arrayOfVariantOfDouble1(8) = 0.000000\n\
sketch1.SetAbsoluteAxisData arrayOfVariantOfDouble1\n\
\n\
part1.InWorkObject = sketch1\n\
\n\
Dim factory2D1 As Factory2D\n\
Set factory2D1 = sketch1.OpenEdition()\n\
\n\
Dim geometricElements1 As GeometricElements\n\
Set geometricElements1 = sketch1.GeometricElements\n\
\n\
Dim axis2D1 As GeometricElement\n\
Set axis2D1 = geometricElements1.Item("AbsoluteAxis")\n\
\n\
Dim line2D1 As CATBaseDispatch\n\
Set line2D1 = axis2D1.GetItem("HDirection")\n\
\n\
line2D1.ReportName = 1\n\
\n\
Dim line2D2 As CATBaseDispatch\n\
Set line2D2 = axis2D1.GetItem("VDirection")\n\
\n\
line2D2.ReportName = 2\n\
\n\
Dim point2D1 As Point2D\n\
Set point2D1 = factory2D1.CreatePoint(-' + x +', ' + y +')\n\
\n\
point2D1.ReportName = 3\n\
\n\
Dim point2D2 As Point2D\n\
Set point2D2 = factory2D1.CreatePoint(' + x +', ' + y +')\n\
\n\
point2D2.ReportName = 4\n\
\n\
Dim line2D3 As Line2D\n\
Set line2D3 = factory2D1.CreateLine(-' + x +', ' + y +', ' + x +', ' + y +')\n\
\n\
line2D3.ReportName = 5\n\
\n\
line2D3.StartPoint = point2D1\n\
\n\
line2D3.EndPoint = point2D2\n\
\n\
Dim point2D3 As Point2D\n\
Set point2D3 = factory2D1.CreatePoint(' + x +', -' + y +')\n\
\n\
point2D3.ReportName = 6\n\
\n\
Dim line2D4 As Line2D\n\
Set line2D4 = factory2D1.CreateLine(' + x +', ' + y +', ' + x +', -' + y +')\n\
\n\
line2D4.ReportName = 7\n\
\n\
line2D4.EndPoint = point2D2\n\
\n\
line2D4.StartPoint = point2D3\n\
\n\
Dim point2D4 As Point2D\n\
Set point2D4 = factory2D1.CreatePoint(-' + x +', -' + y +')\n\
\n\
point2D4.ReportName = 8\n\
\n\
Dim line2D5 As Line2D\n\
Set line2D5 = factory2D1.CreateLine(' + x +', -' + y +', -' + x +', -' + y +')\n\
\n\
line2D5.ReportName = 9\n\
\n\
line2D5.StartPoint = point2D3\n\
\n\
line2D5.EndPoint = point2D4\n\
\n\
Dim line2D6 As Line2D\n\
Set line2D6 = factory2D1.CreateLine(-' + x +', -' + y +', -' + x +', ' + y +')\n\
\n\
line2D6.ReportName = 10\n\
\n\
line2D6.EndPoint = point2D4\n\
\n\
line2D6.StartPoint = point2D1\n\
\n\
Dim constraints1 As Constraints\n\
Set constraints1 = sketch1.Constraints\n\
\n\
Dim reference2 As Reference\n\
Set reference2 = part1.CreateReferenceFromObject(line2D3)\n\
\n\
Dim reference3 As Reference\n\
Set reference3 = part1.CreateReferenceFromObject(line2D1)\n\
\n\
Dim constraint1 As Constraint\n\
Set constraint1 = constraints1.AddBiEltCst(catCstTypeHorizontality, reference2, reference3)\n\
\n\
constraint1.Mode = catCstModeDrivingDimension\n\
\n\
Dim reference4 As Reference\n\
Set reference4 = part1.CreateReferenceFromObject(line2D5)\n\
\n\
Dim reference5 As Reference\n\
Set reference5 = part1.CreateReferenceFromObject(line2D1)\n\
\n\
Dim constraint2 As Constraint\n\
Set constraint2 = constraints1.AddBiEltCst(catCstTypeHorizontality, reference4, reference5)\n\
\n\
constraint2.Mode = catCstModeDrivingDimension\n\
\n\
Dim reference6 As Reference\n\
Set reference6 = part1.CreateReferenceFromObject(line2D4)\n\
\n\
Dim reference7 As Reference\n\
Set reference7 = part1.CreateReferenceFromObject(line2D2)\n\
\n\
Dim constraint3 As Constraint\n\
Set constraint3 = constraints1.AddBiEltCst(catCstTypeVerticality, reference6, reference7)\n\
\n\
constraint3.Mode = catCstModeDrivingDimension\n\
\n\
Dim reference8 As Reference\n\
Set reference8 = part1.CreateReferenceFromObject(line2D6)\n\
\n\
Dim reference9 As Reference\n\
Set reference9 = part1.CreateReferenceFromObject(line2D2)\n\
\n\
Dim constraint4 As Constraint\n\
Set constraint4 = constraints1.AddBiEltCst(catCstTypeVerticality, reference8, reference9)\n\
\n\
constraint4.Mode = catCstModeDrivingDimension\n\
\n\
sketch1.CloseEdition \n\
\n\
part1.InWorkObject = sketch1\n\
\n\
part1.Update \n\
\n\
Dim shapeFactory1 As Factory\n\
Set shapeFactory1 = part1.ShapeFactory\n\
\n\
Dim pad1 As Pad\n\
Set pad1 = shapeFactory1.AddNewPad(sketch1, 70.000000)\n\
\n\
Dim limit1 As Limit\n\
Set limit1 = pad1.FirstLimit\n\
\n\
Dim length1 As Length\n\
Set length1 = limit1.Dimension\n\
\n\
length1.Value = '+ z +'\n\
\n\
pad1.IsSymmetric = True\n\
\n\
part1.Update \n\
\n\
Set partDocument1 = CATIA.ActiveDocument\n\
\n\
partDocument1.SaveAs')
    mcr.write(' "'+os.path.join(os.getcwd(),file_name)+'.CATPart"\n\
\n\
End Sub\n')
    mcr.close()

Now my macro is ready.
I tried the following lines to call this macro but no success.

    #option1
    catia = win32com.client.Dispatch('CATIA.Application')
    catia.StartCommand(file_name + '.CATScript')

    #option2
    os.chdir(r'C:\Program Files\Dassault Systemes\B24\win_b64\code\bin')
    os.system('cnext CATIA.V5R16.B16 -macro'+ os.path.join(os.getcwd(),file_name+'.CATScript'))

Now I would ask if it is possible to call the macro file with pycatia.
Regards

Iterators in pycatia

When working on PR #66, some questions come into my mind:

  1. pycatia use __getitem__ method to make container iterable, but this method seems to be a legacy one. Instead, __iter__ is a modern one. Is there some reason to choose __getitem__? See reference
  2. Containers like Products, which inherit from Collection, could iterate well without defining __getitem__ again in sub_class. It seems redundant here.

Can't install by using piptools

error message:
Collecting pywin32==224 (from pycatia)
ERROR: Could not find a version that satisfies the requirement pywin32==224 (from pycatia) (from versions: 225, 226, 227)
ERROR: No matching distribution found for pywin32==224 (from pycatia)

And install the specific pywin32 version(pip install pywin32==224) also gives an error message, do I need to downgrade the pywin32.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.