[Frage] Are there any functions that can use 3D Text in Python as well? [Gelöst]


In SmartPart, you can use 3D Text by using "TEXT" function.
----<SmartPart Code >----
DEFINE STYLE "font_style" font_name , text_height , anchor_value , 0
SET STYLE "font_style"
COLOR text_color
PEN text_pen
STROKE text_stroke
SCALEX text_stretch
TEXT text_thickness / 1000 , 0 , text_string
TextLen = strlen( text_string )
-------------------------
Are there any functions that can use 3D Text in Python as well?

Lösung anzeigen Lösung verbergen

Hi,

you can make a loop like :

   for i in range(len(bsplines)):
            text_3d = BasisElements.ModelElement3D(self.com_prop, bsplines[i])
            self.model_ele_list_3d.append(text_3d)

or

        for key, bspline in enumerate(bsplines):
            text_3d = BasisElements.ModelElement3D(self.com_prop, bspline)
            self.model_ele_list_3d.append(text_3d)

I see my text well but not as an 3D Object

Best

Hi,

PiCAD (https://www.pi-cad.pl/downloads/) has developped a PythonPart for this but I don't have more information about this...

Best

Note :

There is a Text3DUtil.py file located in ...\Etc\PythonPartsFramework.

Does anyone have any information about it ?

Best

Hi,

you can create BSpline3Ds from a text like

text_3d = Text3DUtil()

if text_3d is None:
return

bsplines = text_3d.get_bsplines(AllplanGeo.Point3D(), text,
TextReferencePointPosition.BOTTOM_LEFT, height, rotation_angle)

After this, you can create ModelElement3Ds from this bsplines and add the elements to the PythonPart.

Best regards
Horst

Thank you for answer.
===code===
:
bsplines = text_3d.get_bsplines(AllplanGeo.Point3D(), text, TextReferencePointPosition.BOTTOM_LEFT, height, rotation_angle)

self.model_elem_list.append(AllplanBasisElements.ModelElement3D(center_props, bsplines))
:
--------

As above, nothing appears.
however,
===code===
self.model_elem_list.append(AllplanBasisElements.ModelElement3D(center_props, bsplines[0]))
--------
Only one object in the array appears.
Can I replace the whole thing with Surface or Solid?

Hi,

you can make a loop like :

   for i in range(len(bsplines)):
            text_3d = BasisElements.ModelElement3D(self.com_prop, bsplines[i])
            self.model_ele_list_3d.append(text_3d)

or

        for key, bspline in enumerate(bsplines):
            text_3d = BasisElements.ModelElement3D(self.com_prop, bspline)
            self.model_ele_list_3d.append(text_3d)

I see my text well but not as an 3D Object

Best

Hello,

you mean you see the text created as 3D curves, but not as 3D solids? Maybe you can try to use the generated splines as a path to extrude a rectangular profile along them?
I would try to do that with the function

NemAll_Python_Geometry.CreateSweptBRep3D()

Zitiert von: bmarciniec
Hello,
you mean you see the text created as 3D curves, but not as 3D solids? Maybe you can try to use the generated splines as a path to extrude a rectangular profile along them?

I would try to do that with the function
NemAll_Python_Geometry.CreateSweptBRep3D()

Hi,

I just try this

err, brep3d_geo = Geometry.CreateSweptBRep3D(bsplines, path, True, True)

It works fine but it needs a min value for the path (15 seems to be the shortest value), so the complete code :

...
        text_3d = Text3DUtil()

        if text_3d is None:
            return

        bsplines = text_3d.get_bsplines(Geometry.Point3D(),
                                        "my text",
                                        TextReferencePointPosition.BOTTOM_LEFT,
                                        100,
                                        Geometry.Angle()
                                        )

        path = Geometry.Polyline3D()
        path += Geometry.Point3D()
        path += Geometry.Point3D(0, 0, 15)
        err, brep3d_geo = Geometry.CreateSweptBRep3D(bsplines, path, True, True)
...