Das Wissen aller Anwender nutzen

Im Allplan Connect Forum tauschen sich Anwender aus, geben wertvolle Tipps oder beraten sich bei ganz konkreten Aufgabenstellungen − auch international.
Und damit wirklich keine Frage unbeantwortet bleibt, unterstützen die Mitarbeiter des Technischen Supports ebenfalls aktiv das Forum.

Es erwarten Sie:

  • Foren-Vielfalt aus CAD Architektur, CAD Ingenieurbau uvm.
  • Tipps von User für User
  • international: Deutsch, Englisch, Italienisch, Französisch und Tschechisch

Melden Sie sich jetzt an und diskutieren Sie mit!

Zur Registrierung

[Frage] Is that possible to modify the length of an existing cuboid using PythonPart?


Hello everyone,

I have a question about modification.

I want to find a way to modify an existing 3D model. I have create a cuboid. But when I want to change the properties such as length or height, which were set at the time of creation, I found it's the class of BRep. I can not find a way to change those properties. I can only cut it etc. The function of CreateCuboid or CreateCylinder returns class of BRep.

Is that possible to change the length or height directly? Or how to convert the class of the geometry from BRep to Class of Cuboid? So I can use the function of Cuboid to set the attributes.

thanks in advance.

Best

Anhänge (1)

Typ: image/png
28-mal heruntergeladen
Größe: 57,39 KiB

Hilfreichste Antwort anzeigen Hilfreichste Antwort verbergen

Zitiert von: ZihanDeng
Hi,
Thanks for your quick reply!
Just as you said, what I want is using PythonPart to change the attributes that I've assigned. For example I have defined a cuboid with 3000,3000,3000. But now I want to change those attributes to maybe 3000,2000,1000 using python parts.
I have already used the ElementsAttributesServer but what I got from GetAttributes is an empty list of attributes.Is that means I need to define the Length or Height again?
Thanks!
Best

Hi!

If you created the cuboid using native Allplan function, or created the cuboid with a python script, without putting it into a PythonPart container at the end of your script, the information about length, width and height is lost. When the cuboid is created in the drawing file, it is saved as a collection of 8 vertices, 12 edges and 6 faces. To be more specific, from that moment its geometry is described with a Polyhedron3D object. There is a way to modify the coordinates of those vertices or generally perform geometrical operations on that cuboid. But this is complicated, and is not just changing a value of height. Cuboid3D is an object, that you can use to create a cuboid only, but after that it is just a Polyhedron3D.

As Christophe mentioned, you can create a parametric object: a PythonPart. In this case you will not lose this information after creation. It will be kept in PythonPart parameters. Optionally it can be kept also in Attributes.

If you want to go the first way: modifying the vertices of a Polyhedron: we will soon publish some examples showing how you can modify a geometry. But I recommend the second way: create a PythonPart at the end of the script.

Best regards,
Bart

11 - 13 (13)

Thanks! For me I would like to firstly choose the first way haha. My problem now is exactly the parametric container.

I've tried to use the second way to solve the problem but I failed.

Best Regards,

See the attachment. The simple Python part is just a cuboid, but put into the container (lines 42 to 47 in SimplePythonPart.py). A attached also a more complex script, showing more of the possibilities, that a PythonPart offers. You can have a look on it, but idk, if it helps you without having the explanation for it, which I am currently creating.

Best regards,
Bart

Anhänge (1)

Typ: application/zip
298-mal heruntergeladen
Größe: 3,96 KiB

Hi,

I'd like to add another simple example : a cuboid but directly placed into a pythonpart

Like Bartlomiej, I'm writing more examples on my blog here with all source code here

Best
Christophe

Anhänge (1)

Typ: application/zip
281-mal heruntergeladen
Größe: 1,80 KiB
11 - 13 (13)