How to create text object in python console

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
harveyclayton
Posts: 1
Joined: Mon Jul 15, 2019 4:37 pm

How to create text object in python console

Post by harveyclayton »

I have tried things like
>>> App.ActiveDocument.addObject("Draft::Text","Tekst")

or

>>> t=Draft.Text.createObject()

but I can't guess how it really works. I could not find any good documentation and examples about Draft module either.

I am using:
FreeCAD 0.10.3142 on OpenSUSE 11.1, 64-bit

I am just sneezing the python scripting possibilities in FreeCAD, looks absoluetly fascinating!!!
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: How to create text object in python console

Post by jmaustpc »

harveyclayton wrote: Mon Jul 15, 2019 4:41 pm FreeCAD 0.10.3142
What? you can't be really, that is obsolete beyond all reason, it almost predates every piece of FreeCAD's functionality, I very much doubt it is right.

Please post your version data in the manner explained in the forum rules link above this forum.

You can create an annotation from Python or a Draft WB text object.

the following works

Code: Select all

FreeCAD.ActiveDocument.addObject("App::AnnotationLabel","MyNote").LabelText=["This is my note"]



OS: Ubuntu 18.04.2 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Python version: 3.6.8
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/Australia (en_AU)
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: How to create text object in python console

Post by jmaustpc »

Also the Draft WB tools wiki pages show you (at the bottom) how to create them from Python

Draft_Label

Draft_Text
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: How to create text object in python console

Post by openBrain »

With their brother Draft ShapeString ;)
Post Reply