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

Create Geometry by vertices, edges and faces [Gelöst]


Hey an alle,

ich würde gerne nur zu visualisierungszwecken über die python API in Allplan eine Geometrie visualisieren die mir in als Punkt, Kanten und Faces Arrays vorliegen. Ich dachte dass es möglich sein könnte das als Polyhedron3D zu erzeugen. Leider bin ich dazu nicht in der Lage, auch weil die Beispiele in der Dokumentation äußerst verwirrend sind.

Bezug nehmen auf diese Seite: https://pythonparts.allplan.com/ und der Beschreibung dort des Polyhedron3D. Hier steht:

Sample of code

Polyhedron3D polyhedron(tEdges, 4/vertices/, 4/edges/, 1/faces/, false/positive orientation/);

//APPEND VERTICES
int err = polyhedron.AppendVertex(Point3D(0., 0., 0.));
assert(err==eOK);
err = polyhedron.AppendVertex(Point3D(10., 0., 0.));
assert(err==eOK);
// append next vertices ...

// APPEND EDGES
GeometryEdge edge1(0,1), edge2(1,2), edge3(2,3);
err = polyhedron.AppendEdge(edge1);
assert(err==eOK);
// append next edges ...

// APPEND FACES
PolyhedronFace face = polyhedron.CreateFace(3/expected edges/);
face.AppendEdge(OrientedEdge(0/EdgeHandle/, true /orientation from start to end index/
// append next edges into face ...

Nur leider hat das Polyhedron keine Methode .AppendVertex . Dann dachte ich ich könnte hierfür ja gegebenenfalls den Polyhedron3DBuilder verwenden. Der Polyhedron3DBuilder hat ja die Methode .AppendVertex. Nur der Polyhedron3DBuilder hat weder die Methode .AppendEdge noch ein .AppendFace oder CreateFace.

Oder bin ich generell auf dem falschen weg?

Lösung anzeigen Lösung verbergen

..und in diesem Beispiel wird ein Würfel (als Volumenkörper) erstellt:

polyhedron = AllplanGeo.Polyhedron3D(AllplanGeo.PolyhedronType.tVolume,8,12,6,True)
builder = AllplanGeo.Polyhedron3DBuilder(polyhedron)

builder.AppendVertex(AllplanGeo.Point3D(0., 0., 0.)) #0
builder.AppendVertex(AllplanGeo.Point3D(1000.0, 0., 0.)) #1
builder.AppendVertex(AllplanGeo.Point3D(1000.0, 1000.0, 0.)) #2
builder.AppendVertex(AllplanGeo.Point3D(0., 1000.0, 0.)) #3

builder.AppendVertex(AllplanGeo.Point3D(0., 0., 1000.0)) #4
builder.AppendVertex(AllplanGeo.Point3D(1000.0, 0., 1000.0)) #5
builder.AppendVertex(AllplanGeo.Point3D(1000.0, 1000.0, 1000.0)) #6
builder.AppendVertex(AllplanGeo.Point3D(0., 1000.0, 1000.0)) #7

e0=AllplanGeo.GeometryEdge(0,1)
e1=AllplanGeo.GeometryEdge(1,2)
e2=AllplanGeo.GeometryEdge(2,3)
e3=AllplanGeo.GeometryEdge(3,0)

e4=AllplanGeo.GeometryEdge(0,4)
e5=AllplanGeo.GeometryEdge(1,5)
e6=AllplanGeo.GeometryEdge(2,6)
e7=AllplanGeo.GeometryEdge(3,7)

e8=AllplanGeo.GeometryEdge(4,5)
e9=AllplanGeo.GeometryEdge(5,6)
e10=AllplanGeo.GeometryEdge(6,7)
e11=AllplanGeo.GeometryEdge(7,4)

polyhedron.AppendEdge(e0)
polyhedron.AppendEdge(e1)
polyhedron.AppendEdge(e2)
polyhedron.AppendEdge(e3)
polyhedron.AppendEdge(e4)
polyhedron.AppendEdge(e5)
polyhedron.AppendEdge(e6)
polyhedron.AppendEdge(e7)
polyhedron.AppendEdge(e8)
polyhedron.AppendEdge(e9)
polyhedron.AppendEdge(e10)
polyhedron.AppendEdge(e11)

#bottom
bottom=polyhedron.CreateFace(4)
bottom.AppendEdge(0,True)
bottom.AppendEdge(1,True)
bottom.AppendEdge(2,True)
bottom.AppendEdge(3,True)

#front
front=polyhedron.CreateFace(4)
front.AppendEdge(4,True)
front.AppendEdge(8,True)
front.AppendEdge(5,False)
front.AppendEdge(0,False)

#right
right=polyhedron.CreateFace(4)
right.AppendEdge(5,True)
right.AppendEdge(9,True)
right.AppendEdge(6,False)
right.AppendEdge(1,False)

#back
back=polyhedron.CreateFace(4)
back.AppendEdge(6,True)
back.AppendEdge(10,True)
back.AppendEdge(7,False)
back.AppendEdge(2,False)

#left
left=polyhedron.CreateFace(4)
left.AppendEdge(7,True)
left.AppendEdge(11,True)
left.AppendEdge(4,False)
left.AppendEdge(3,False)

#top
top=polyhedron.CreateFace(4)
top.AppendEdge(11,False)
top.AppendEdge(10,False)
top.AppendEdge(9,False)
top.AppendEdge(8,False)

builder.Complete()

com_prop = AllplanBaseElements.CommonProperties()
com_prop.GetGlobalProperties()
com_prop.Pen = 1
com_prop.Color = 12
com_prop.Stroke = 1

self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, polyhedron))

Hallo,

über den Polyhedron3DBuilder wird das Polyhedron mit dem Builder verbunden:

__init__( (object)arg1, (Polyhedron3D)polyhedron) -> None :
Constructor

Parameter: polyhedron Polyhedron where vertices will be modified

Damit können AppendEdge, ... auf polyhedron angewendet werden.

Viele Grüße
Horst

Hier mal ein Beispiel, wo eine quadraische Fläche als Polyhedron erstellt wird:

polyhedron = AllplanGeo.Polyhedron3D(AllplanGeo.PolyhedronType.tFaces,4,4,1,True)

builder = AllplanGeo.Polyhedron3DBuilder(polyhedron)

builder.AppendVertex(AllplanGeo.Point3D(0., 0., 0.))
builder.AppendVertex(AllplanGeo.Point3D(1000.0, 0., 0.))
builder.AppendVertex(AllplanGeo.Point3D(1000.0, 1000.0, 0.))
builder.AppendVertex(AllplanGeo.Point3D(0., 1000.0, 0.))

edge1=AllplanGeo.GeometryEdge(0,1)
edge2=AllplanGeo.GeometryEdge(1,2)
edge3=AllplanGeo.GeometryEdge(2,3)
edge4=AllplanGeo.GeometryEdge(3,0)

polyhedron.AppendEdge(edge1)
polyhedron.AppendEdge(edge2)
polyhedron.AppendEdge(edge3)
polyhedron.AppendEdge(edge4)

face=polyhedron.CreateFace(4)
face.AppendEdge(0,True)
face.AppendEdge(1,True)
face.AppendEdge(2,True)
face.AppendEdge(3,True)

builder.Complete()

com_prop = AllplanBaseElements.CommonProperties()
com_prop.GetGlobalProperties()
com_prop.Pen = 1
com_prop.Color = 12
com_prop.Stroke = 1

self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, polyhedron))

..und in diesem Beispiel wird ein Würfel (als Volumenkörper) erstellt:

polyhedron = AllplanGeo.Polyhedron3D(AllplanGeo.PolyhedronType.tVolume,8,12,6,True)
builder = AllplanGeo.Polyhedron3DBuilder(polyhedron)

builder.AppendVertex(AllplanGeo.Point3D(0., 0., 0.)) #0
builder.AppendVertex(AllplanGeo.Point3D(1000.0, 0., 0.)) #1
builder.AppendVertex(AllplanGeo.Point3D(1000.0, 1000.0, 0.)) #2
builder.AppendVertex(AllplanGeo.Point3D(0., 1000.0, 0.)) #3

builder.AppendVertex(AllplanGeo.Point3D(0., 0., 1000.0)) #4
builder.AppendVertex(AllplanGeo.Point3D(1000.0, 0., 1000.0)) #5
builder.AppendVertex(AllplanGeo.Point3D(1000.0, 1000.0, 1000.0)) #6
builder.AppendVertex(AllplanGeo.Point3D(0., 1000.0, 1000.0)) #7

e0=AllplanGeo.GeometryEdge(0,1)
e1=AllplanGeo.GeometryEdge(1,2)
e2=AllplanGeo.GeometryEdge(2,3)
e3=AllplanGeo.GeometryEdge(3,0)

e4=AllplanGeo.GeometryEdge(0,4)
e5=AllplanGeo.GeometryEdge(1,5)
e6=AllplanGeo.GeometryEdge(2,6)
e7=AllplanGeo.GeometryEdge(3,7)

e8=AllplanGeo.GeometryEdge(4,5)
e9=AllplanGeo.GeometryEdge(5,6)
e10=AllplanGeo.GeometryEdge(6,7)
e11=AllplanGeo.GeometryEdge(7,4)

polyhedron.AppendEdge(e0)
polyhedron.AppendEdge(e1)
polyhedron.AppendEdge(e2)
polyhedron.AppendEdge(e3)
polyhedron.AppendEdge(e4)
polyhedron.AppendEdge(e5)
polyhedron.AppendEdge(e6)
polyhedron.AppendEdge(e7)
polyhedron.AppendEdge(e8)
polyhedron.AppendEdge(e9)
polyhedron.AppendEdge(e10)
polyhedron.AppendEdge(e11)

#bottom
bottom=polyhedron.CreateFace(4)
bottom.AppendEdge(0,True)
bottom.AppendEdge(1,True)
bottom.AppendEdge(2,True)
bottom.AppendEdge(3,True)

#front
front=polyhedron.CreateFace(4)
front.AppendEdge(4,True)
front.AppendEdge(8,True)
front.AppendEdge(5,False)
front.AppendEdge(0,False)

#right
right=polyhedron.CreateFace(4)
right.AppendEdge(5,True)
right.AppendEdge(9,True)
right.AppendEdge(6,False)
right.AppendEdge(1,False)

#back
back=polyhedron.CreateFace(4)
back.AppendEdge(6,True)
back.AppendEdge(10,True)
back.AppendEdge(7,False)
back.AppendEdge(2,False)

#left
left=polyhedron.CreateFace(4)
left.AppendEdge(7,True)
left.AppendEdge(11,True)
left.AppendEdge(4,False)
left.AppendEdge(3,False)

#top
top=polyhedron.CreateFace(4)
top.AppendEdge(11,False)
top.AppendEdge(10,False)
top.AppendEdge(9,False)
top.AppendEdge(8,False)

builder.Complete()

com_prop = AllplanBaseElements.CommonProperties()
com_prop.GetGlobalProperties()
com_prop.Pen = 1
com_prop.Color = 12
com_prop.Stroke = 1

self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, polyhedron))

Perfekt! Vielen Dank @Nemo. Funktioniert wie beschrieben und war genau das was ich gebraucht habe!


https://campus.allplan.com/ verwendet Cookies  -  Mehr Informationen

Akzeptieren