efdiloreto / PyTekla

Bringing CPython power to Tekla
MIT License
7 stars 3 forks source link

excellent #2

Closed better319 closed 10 months ago

better319 commented 10 months ago

excellent job, i am not good at c#,your work hlep me. i need an example to create plate by position sothat i can conbine cad with tekla to create different sharp.

better319 commented 10 months ago

in addition,for others, pip install -r requirements.txt

it's better to intall other deplay.

don't use jupyternotebook

efdiloreto commented 10 months ago

Thanks! About the example, yes sure I can do it.

better319 commented 10 months ago

`import sys from pytekla import wrap

model = wrap("Model.Model")

if not model.get_connection_status(): print("Cannot connect with Tekla model") sys.exit()

material = wrap("Model.Material") material.material_string = "Q235B"

BentPlate_profile = wrap("Model.Profile") BentPlate_profile.profile_string = "PL10"

BentPlate_position = wrap("Model.Position") BentPlate_position.rotation_offset = 90 BentPlate_position.depth = wrap("Model.Position.DepthEnum").BEHIND

BentPlate = wrap("Model.BentPlate") BentPlate.start_point = wrap("Geometry3d.Point", 0.0, 0.0, 0.0) BentPlate.add_point = wrap("Geometry3d.Point", 10.0, 0.0, 0.0) ############error?? BentPlate.end_point = wrap("Geometry3d.Point", 0, 30.0, 0.0) BentPlate.name = "PYTEKLA BentPlate" BentPlate._class = "42" # Cannot use "class" in lowercase BentPlate.profile = BentPlate_profile BentPlate.material = material BentPlate.position = BentPlate_position BentPlate.insert()

model.commit_changes("BentPlate creation") `

but it's not work..

efdiloreto commented 10 months ago

@better319 Give me couple a days to create a full example. In the meantime, I'm seeing some errors when you try to set the geometry in the BentPlate.

To set the geometry of the BentPlate you need to use the Geometry Property.

To do that you need to create a ConnectiveGeometry first. This class allows to pass to the constructor a Contour.

So, the code should look like this:

# Defining the contour
contour = wrap("Model.Contour")

# Supposing you have a list of points [(x1, y1, z1).....]
for p in points:
    geometry_point = wrap("Geometry3d.Point", *p)
    contour_point = wrap("Model.ContourPoint")
    contour_point.set_point(geometry_point)
    contour.add_contour_point(contour_point)

geometry = wrap("Model.ConnectiveGeometry", contour)

bent_plate = wrap("Model.BentPlate")
bent_plate.geometry = geometry
better319 commented 10 months ago
import sys
from pytekla import wrap

model = wrap("Model.Model")
if not model.get_connection_status():
    print("Cannot connect with Tekla model")
    sys.exit()

material = wrap("Model.Material")
material.material_string = "Q235B"

BentPlate_profile = wrap("Model.Profile")
BentPlate_profile.profile_string = "PL10"

BentPlate_position = wrap("Model.Position")
BentPlate_position.rotation_offset = 90
BentPlate_position.depth = wrap("Model.Position.DepthEnum").BEHIND

# Defining the contour
contour = wrap("Model.Contour")

# Supposing you have a list of points [(x1, y1, z1).....]
points=[(1,0,0),(4,0,0),(0,5,0),(4,7,0)]
for p in points:
    geometry_point = wrap("Geometry3d.Point", *p)
    contour_point = wrap("Model.ContourPoint")
    contour_point.set_point(geometry_point)
    contour.add_contour_point(contour_point)

geometry = wrap("Model.ConnectiveGeometry", contour)
BentPlate = wrap("Model.BentPlate")
BentPlate.geometry = geometry
#BentPlate.start_point = wrap("Geometry3d.Point", 0.0, 0.0, 0.0)
#BentPlate.add_point = wrap("Geometry3d.Point", 10.0, 0.0, 0.0)   ############error??
#BentPlate.end_point = wrap("Geometry3d.Point", 0, 30.0, 0.0)
BentPlate.name = "PYTEKLA BentPlate"
BentPlate._class = "42"  # Cannot use "class" in lowercase
BentPlate.profile = BentPlate_profile
BentPlate.material = material
BentPlate.position = BentPlate_position
BentPlate.insert()
model.commit_changes("BentPlate creation")

Traceback (most recent call last): File "C:\Users\Administrator\Desktop\PyTekla-main\create Plate.py", line 41, in BentPlate.insert() File "C:\Users\Administrator\AppData\Roaming\Python\Python311\site-packages\pytekla\wrappers.py", line 50, in wrapper result = func(*args, **kwargs) System.ArgumentException: Required information missing - Geometry, at least 2 nodes required

Tekla.Structures.Model.BentPlate.BentPlateParametersCheck() Tekla.Structures.Model.BentPlate.CreateInstance()

efdiloreto commented 10 months ago

@better319 I think you are missing a step, depending on how you want to create the bent plate. This might be useful for you:

https://github.com/TrimbleSolutionsCorporation/TSOpenAPIExamples/blob/169a670a567feeba2abdb11773f95997a32ab876/Model/Applications/BentPlateExample/BentPlateSampleCreation/Form1.cs#L240

better319 commented 10 months ago

HERE IS THE ERROR

BentPlate = wrap("Model.BentPlate") ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ BentPlate = wrap("Model.ContourPlate")

better319 commented 10 months ago

THANKS