Line 3D chamfer

Schlagworte:
  • Allplan 2024

Dear All,

I'm strugling with chamfer between 2 3D lines. The code creates two 3Dlines but it cannot create chamfer between them. Could you inform me what I should change to get what i want:

# pkt. startowy 0
Lokalizacja_X1 = 0

IV_podstawa4_1 = AllplanGeo.Point3D(Lokalizacja_X1, 0, 0)

# pkt. 1
IV_podstawa4_2 = AllplanGeo.Point3D(Lokalizacja_X1, 0, self.H6)
#
# pkt. 2
IV_podstawa4_3 = AllplanGeo.Point3D(
Lokalizacja_X1,
self.B1/2 - self.B21/2,
self.H6 + self.H5
)
#---------------------------------------

Linia3D_1 = AllplanGeo.Line3D(IV_podstawa4_1, IV_podstawa4_2)

Linia3D_2 = AllplanGeo.Line3D(IV_podstawa4_2, IV_podstawa4_3)

input_pnt = AllplanGeo.Point3D(IV_podstawa4_2)

result, intersect_pnt = AllplanGeo.IntersectionCalculus(Linia3D_1, Linia3D_2)

chamfer_width = self.chamfer #(it's defined in _init part)

if not GeometryValidate.intersection(result):
return

plane = AllplanGeo.Plane3D(Linia3D_1.GetStartPoint(),
Linia3D_1.GetEndPoint(),
Linia3D_2.GetEndPoint())

chamfer_line = AllplanGeo.ChamferCalculus.CalculateApplicableChamfers(
Linia3D_1, Linia3D_2, plane, intersect_pnt, chamfer_width)

com_prop = AllplanBaseElements.CommonProperties()

com_prop.GetGlobalProperties()
com_prop.Pen = 1
com_prop.Color = 6

self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, Linia3D_1))
self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, Linia3D_2))
self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, chamfer_line))

Anhänge (1)

Typ: image/png
12-mal heruntergeladen
Größe: 5,48 KiB

Hi,

if you know the orientation of the lines and that they are intersecting at their ends, you can just trim both lines by the chamfer width and create the chamfer by connecting first line's end point with the second line's start point.

So step-by-step. We have some three points and a chamfer width (I just put some values because I don't know yours):

points = [AllplanGeo.Point3D(0, 0, 0),
          AllplanGeo.Point3D(0, 0, 400),
          AllplanGeo.Point3D(0,-500, 500)]

chamfer_width = 20.0

Now we define two lines:
  • first line starts in the first point and ends in the second point
  • second line starts where the first line ends and goes to the third point
lines = [AllplanGeo.Line3D(points[0], points[1]),
         AllplanGeo.Line3D(points[1], points[2])]

Now trim the first line at the end, and the second line at the start by chamfer width:

lines[0].TrimEnd(chamfer_width)
lines[1].TrimStart(chamfer_width)

And create the chamfer line:
chamfer_line = AllplanGeo.Line3D(lines[0].EndPoint, lines[1].StartPoint)

Now your piece code comes into place:
self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, lines[0]))
self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, lines[1]))
self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, chamfer_line))

Is it what you were looking for? I didn't use the ChamferCalculus, because it is designated for more generic case: where you don't know, whether the chamfered lines cross each other, have common end points or don't cross at all. This is also why using it is much more complicated. If you know, that the two lines you want to chamfer have a common end point and you know their orientation, you can simply trim them.

Best,
Bart

Bart,

it works perfectly . Thanks

Bart,

is there any chance to get from you support, if it comes to fillet of two 3D lines?

I'm trying to do this with AllplanGeo.FilletCalulate3D.Calculate(Line3D[0], Line3D[1], fillet) but it doesn't work for me.

Hi,

Is the Line3D a variable? Because Line3D is also a name of a class in the NemAll_Python_Geometry module. Please stick to conventions:

  • variable names: snake_case
  • classes: CamelCase

Otherwise it will be confusing for all of us.

Zitiert von: mpaa0llplan
...
I'm trying to do this with AllplanGeo.FilletCalulate3D.Calculate(Line3D[0], Line3D[1], fillet) but it doesn't work for me.

I can't help, when I don't see, what is behind all the three variables. Maybe the two lines are not coplanar, maybe the fillet value exceeds the length of one of the lines, maybe some other reason. Actually, the function returns a tuple with the first element being the error code that should tell you what went wrong.

Please provide more information.

Best,
Bart

The code is similar to that one regarding chamfer:

Lokalizacja_X1 = 500

IV_podstawa = [AllplanGeo.Point3D(Lokalizacja_X1, 0, 0),
AllplanGeo.Point3D(Lokalizacja_X1, 0, self.H6),
AllplanGeo.Point3D(Lokalizacja_X1, self.B1/2 - self.B21/2, self.H6 +self.H5)]

radius = 50
#---------------------------------------
Linia = [AllplanGeo.Line3D(IV_podstawa[0], IV_podstawa[1]),
AllplanGeo.Line3D(IV_podstawa[1], IV_podstawa[2])]

Linia1 = Linia[0]Linia2 = Linia[1]

fillet = AllplanGeo.FilletCalculus3D.Calculate(Linia1, Linia2, radius)

com_prop = AllplanBaseElements.CommonProperties()

com_prop.GetGlobalProperties()
com_prop.Pen = 1
com_prop.Color = 6
#Line3D = AllplanGeo.Line3DList.append(Linia3D_1, Linia3D_2)
self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, Linia1))
self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, Linia2))
self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, fillet))

Hi,

FilletCalculus3D.Calculate does not simply return the fillet. It returns a tuple with four elements in it: error code, adapted first line, adapted second line and the fillet. See documentation. You have to unpack the values:

err, first_line, second_line, fillet = AllplanGeo.FilletCalculus3D.Calculate(Linia1, Linia2, radius)
Then you can create ModelElement3D, but only if the fillet gave no errors:

if err == AllplanGeometry.eFilletErrorCode.eNO_ERROR
    self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, first_line))
    self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, second_line))
    self.model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, fillet))

Have a look at this example, lines 231-241

Best,
Bart