Line3D to polygon3D


Hi,

I have created 4 lines3D, which create rectangular:

Line1 = AllplanGeo.Line3D(AllplanGeo.Point3D(0, 0, 0), AllplanGeo.Point3D(10, 0, 0))
Line2 = AllplanGeo.Line3D(AllplanGeo.Point3D(10, 0, 0), AllplanGeo.Point3D(10, 0, 10))
Line3 = AllplanGeo.Line3D(AllplanGeo.Point3D(10, 0, 10), AllplanGeo.Point3D(0, 0, 10))
Line4 = AllplanGeo.Line3D(AllplanGeo.Point3D(0, 0, 10), AllplanGeo.Point3D(0, 0, 0))

self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, Line1 ))
self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, Line2 ))
self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, Line3 ))
self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, Line4))

and after square is created, I'd like to change it into polygon3D

How can I achive that?

MPA

Cita de: mpaa0llplan
Hi,
...
and after square is created, I'd like to change it into polygon3D
How can I achive that?
MPA

Hi,

I am not sure, if I understood it right, but to create such rectangle in the drawing file, go for something like this:

rectangle = AllplanGeo.Polyline3D([AllplanGeo.Point3D(0, 0, 0),
                                   AllplanGeo.Point3D(10, 0, 0),
                                   AllplanGeo.Point3D(10, 0, 10),
                                   AllplanGeo.Point3D(0, 0, 10),
                                   AllplanGeo.Point3D(0, 0, 0)])

self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, rectangle))
This creates a polyline in Allplan.

And if after that you need a polygon, create it from the points:

polygon = AllplanGeo.Polygon3D(rectangle.Points)

Best,
Bart

Hi,

it's not really what I was expecting (I've have already created a lot o polygons using this procedure). Maybe my example was wrong, because I've talked about general situation when a shape of my model isn't regular and is combined with 3Dlines, 3DArcs etc. Please refer to the attached picture. How to convert those elements to polygon3D? So I don't want to convert only straight lines into polyline and then polygon but any shape

Adjuntos (1)

Type: image/png
Descargado 16 veces
Size: 6,86 KiB

Hi,

ah, now this is getting clearer. Well, a Polygon3D in the geometry module of Allplan is (similarly to a Polyline3D) described by an ordered list of points. Arc is not a bunch of points, it's a curve. It must be turned into a bunch of points in a process called polygonization. You can polygonize a 3d arc like this

arc_3d = AllplanGeo.Arc3D(AllplanGeo.Point3D(), 100.0, 100.0, 0.0, 3.14159)
polygonized_arc = AllplanGeo.Polygonize(arc_3d, 12)

You will get a polyline with 12 segments and 13 points.
If you have other non-polygonal curves, you must polygonize them into a Polyline3D as well. Then you can get the points of all these polylines, put them into one list and create a polygon:

points = []
points.extend(polygonized_arc.Points)
points.extend(some_other_polyline.Points)
...
polygon = AllplanGeo.Polygon3D(points)

Of course it's a tricky task, because you have to pay attention to the orientation, make sure all points are coplanar and that the polygon is closed and not self-intersecting.

I don't see another option if you want to get a Polygon3D as a result.

Hope that helps!

Best,
Bart

Hi,

It seems that when you polygonized Arc3D it needs to be rotated. My drawings is parallel to grid "y"

fillet = AllplanGeo.Arc3D(AllplanGeo.Point3D(fillet.Center),radius, radius,0.0, 3.14159)
polygonized_fillet = AllplanGeo.Polygonize(fillet, 12)

Please refer to the list of arc3d coordinates below:

fillet: Polyline3D(
Count(13)
Points(
(3915, 30, 83.6531611374)
(3913.9777765057, 37.7645649451, 83.6531611374)
(3910.9807687475, 44.9999885096, 83.6531611374)
(3906.2132175084, 51.2131893628, 83.6531611374)
(3900.0000229808, 55.9807488456, 83.6531611374)
(3892.7646033927, 58.9777662037, 83.6531611374)
(3885.0000398038, 60, 83.6531611374)
(3877.2354735024, 58.9777868076, 83.6531611374)
(3870.0000459615, 55.9807886494, 83.6531611374)
(3863.7868387828, 51.2132456539, 83.6531611374)
(3859.0192710564, 45.0000574519, 83.6531611374)
(3856.0222440984, 37.7646418403, 83.6531611374)
(3855.0000000001, 30.0000796077, 83.6531611374)))

In my case coordinate "x" should be const and as you can see coordinate "z" is const.

Hi,

I've cretaed a random shape of a polygon using AllplanGeo.Point3D as below:

# --------------------------------------------------
com_prop = AllplanBaseElements.CommonProperties()

com_prop.GetGlobalProperties()
com_prop.Pen = 1
com_prop.Color = 6
#---------------------------------------------------
#--------------------------------------------------
com_prop_fillet = AllplanBaseElements.CommonProperties()

com_prop_fillet.GetGlobalProperties()
com_prop_fillet.Pen = 1
com_prop_fillet.Color = 15

#-------START PART
Lokalizacja_X = 1000
Points_START = [
AllplanGeo.Point3D(Lokalizacja_X,0,0),
AllplanGeo.Point3D(Lokalizacja_X,1000,0),
AllplanGeo.Point3D(Lokalizacja_X,1500,500),
AllplanGeo.Point3D(Lokalizacja_X,1500,1000),
AllplanGeo.Point3D(Lokalizacja_X,1000,1000),
AllplanGeo.Point3D(Lokalizacja_X,0,0)
]

points_final_START = []
points_final_START.extend(Points_START)

Polygon_START = AllplanGeo.Polygon3D(points_final_START)

#-------END PART
Lokalizacja_X = Lokalizacja_X + 1000
Points_End = [
AllplanGeo.Point3D(Lokalizacja_X,0,0),
AllplanGeo.Point3D(Lokalizacja_X,1000,0),
AllplanGeo.Point3D(Lokalizacja_X,1500,500),
AllplanGeo.Point3D(Lokalizacja_X,1500,1000),
AllplanGeo.Point3D(Lokalizacja_X,1000,1000),
AllplanGeo.Point3D(Lokalizacja_X,0,0)
]

points_final_END = []
points_final_END.extend(Points_End)

Polygon_END = AllplanGeo.Polygon3D(points_final_END)

err, polyhedron = AllplanGeo.CreatePolyhedron(Polygon_START, Polygon_END)

#----------------------------------------------------------------------------------------------------
return [AllplanBasisElements.ModelElement3D(com_prop, polyhedron)]

But nothing was created on screen.

I've received drawing with polyhedron3D as per attached file but without arc3D. Only lines

Any ideas what's going on:

fillet = AllplanGeo.Arc3D(AllplanGeo.Point3D(fillet.Center),radius, radius,0.0, 3.14159)
fillet2 = AllplanGeo.Arc3D(AllplanGeo.Point3D(fillet2.Center),radius2, radius2,0.0, 3.14159)
fillet3 = AllplanGeo.Arc3D(AllplanGeo.Point3D(fillet3.Center),radius2, radius2,0.0, 3.14159)
fillet4 = AllplanGeo.Arc3D(AllplanGeo.Point3D(fillet4.Center),radius, radius,0.0, 3.14159)
fillet5 = AllplanGeo.Arc3D(AllplanGeo.Point3D(fillet5.Center),radius, radius,0.0, 3.14159)
fillet6 = AllplanGeo.Arc3D(AllplanGeo.Point3D(fillet6.Center),radius2, radius2,0.0, 3.14159)
fillet7 = AllplanGeo.Arc3D(AllplanGeo.Point3D(fillet7.Center),radius2, radius2,0.0, 3.14159)
fillet8 = AllplanGeo.Arc3D(AllplanGeo.Point3D(fillet8.Center),radius, radius,0.0, 3.14159)

#-------START obrót FILLET o kat

angle_fillet = AllplanGeo.Angle()
angle_fillet.Deg = 0

rotation_axis = AllplanGeo.Line3D(AllplanGeo.Point3D(0, 0, 0),
AllplanGeo.Point3D(0, 1, 0))

transformation_matrix_fillet = AllplanGeo.Matrix3D()
transformation_matrix_fillet.SetRotation(rotation_axis, angle_fillet)

rotation_axis = AllplanGeo.Line3D(AllplanGeo.Point3D(0, 0, 0),
AllplanGeo.Point3D(0, 0, 0))

transformation_matrix_fillet = AllplanGeo.Matrix3D()
transformation_matrix_fillet.SetRotation(rotation_axis, angle_fillet)

#-------KONIEC obrót FILLET o kat
fillet = AllplanGeo.Transform(fillet, transformation_matrix_fillet)
fillet2 = AllplanGeo.Transform(fillet2, transformation_matrix_fillet)
fillet3 = AllplanGeo.Transform(fillet3, transformation_matrix_fillet)
fillet4 = AllplanGeo.Transform(fillet4, transformation_matrix_fillet)
fillet5 = AllplanGeo.Transform(fillet5, transformation_matrix_fillet)
fillet6 = AllplanGeo.Transform(fillet6, transformation_matrix_fillet)
fillet7 = AllplanGeo.Transform(fillet7, transformation_matrix_fillet)
fillet8 = AllplanGeo.Transform(fillet8, transformation_matrix_fillet)

polygonized_fillet = AllplanGeo.Polygonize(fillet, 12)
polygonized_fillet2 = AllplanGeo.Polygonize(fillet2, 12)
polygonized_fillet3 = AllplanGeo.Polygonize(fillet3, 12)
polygonized_fillet4 = AllplanGeo.Polygonize(fillet4, 12)
polygonized_fillet5 = AllplanGeo.Polygonize(fillet5, 12)
polygonized_fillet6 = AllplanGeo.Polygonize(fillet6, 12)
polygonized_fillet7 = AllplanGeo.Polygonize(fillet7, 12)
polygonized_fillet8 = AllplanGeo.Polygonize(fillet8, 12)

Points_START = [
AllplanGeo.Line3D.GetStartPoint(chamfer_line1),
AllplanGeo.Line3D.GetEndPoint(first_line),
AllplanGeo.Line3D.GetStartPoint(second_line),
AllplanGeo.Line3D.GetEndPoint(third_line),
AllplanGeo.Line3D.GetStartPoint(fourth_line),
AllplanGeo.Line3D.GetEndPoint(fifth_line),
AllplanGeo.Line3D.GetStartPoint(sixth_line),
AllplanGeo.Line3D.GetEndPoint(seventh_line),
AllplanGeo.Line3D.GetStartPoint(eigth_line),
AllplanGeo.Line3D.GetStartPoint(chamfer_line2),
AllplanGeo.Line3D.GetEndPoint(chamfer_line2),
AllplanGeo.Line3D.GetStartPoint(chamfer_line3),
AllplanGeo.Line3D.GetEndPoint(chamfer_line3),
AllplanGeo.Line3D.GetEndPoint(nineth_line),
AllplanGeo.Line3D.GetStartPoint(tenth_line),
AllplanGeo.Line3D.GetEndPoint(eleventh_line),
AllplanGeo.Line3D.GetStartPoint(twelfth_line),
AllplanGeo.Line3D.GetEndPoint(thirteenth_line),
AllplanGeo.Line3D.GetStartPoint(fourteenth_line),
AllplanGeo.Line3D.GetEndPoint(fifteenth_line),
AllplanGeo.Line3D.GetStartPoint(sixteenth_line),
AllplanGeo.Line3D.GetStartPoint(chamfer_line4),
AllplanGeo.Line3D.GetEndPoint(chamfer_line4),
AllplanGeo.Line3D.GetEndPoint(chamfer_line1),
AllplanGeo.Line3D.GetStartPoint(chamfer_line1)

]

points_final_START = []

points_final_START.extend(Points_START)
points_final_START.extend(polygonized_fillet.Points)
points_final_START.extend(polygonized_fillet2.Points)
points_final_START.extend(polygonized_fillet3.Points)
points_final_START.extend(polygonized_fillet4.Points)
points_final_START.extend(polygonized_fillet5.Points)
points_final_START.extend(polygonized_fillet6.Points)
points_final_START.extend(polygonized_fillet7.Points)
points_final_START.extend(polygonized_fillet8.Points)

print("fillet START: "
+ str(polygonized_fillet))

print("fillet2 START: "
+ str(polygonized_fillet2))
print("points START: "
+ str(Points_START))
print("points final START: "
+ str(points_final_START))

Polygon_START = AllplanGeo.Polygon3D(points_final_START)

The part with 2nd polygon is similar to that one but instead of ending START there is ending END

Adjuntos (1)

Type: image/jpeg
Descargado 8 veces
Size: 56,10 KiB