Python Forum
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text frame
#1
Python and AutoCAD

Hi All

Anyone has a code or and idea how to draw in AutoCAD tight (offset = 0 ?) frame around text using python coding? I need it for larger code and can not use AutoCAD utilities

Thanks

Attached Files

Thumbnail(s)
   
Reply
#2
you can go through the related packages and see if anything fits.
Reply
#3
No idea how to do that using Python within AutoCAD, but you can do this in reportlab and save the pdf.

You have to write the text and the box to something and save it.

#https://docs.reportlab.com/reportlab/userguide/ch11_graphics/

from reportlab.graphics import shapes, renderPDF
from reportlab.graphics.charts.textlabels import Label
from reportlab.graphics.shapes import Drawing
from reportlab.lib import colors 
from reportlab.lib.pagesizes import A4

mypdf = 'reportlab/pdfs/rotate_text_in_rectangles.pdf'
width, height = A4
d = Drawing(width, height)
# mark the origin of the label
d.add(shapes.Circle(200,500, 7, fillColor=colors.green))
label = Label()
# define the properties of label
# change 1 property, repeat d.add(label) and renderPDF.drawToFile(d, mypdf, 'What\'s this?') to see the modification
label.setOrigin(200,500)
lab.boxAnchor = 'ne'
label.angle = 45
label.dx = 0
label.dy = -20
label.boxStrokeColor = colors.pink
label.boxStrokeWidth = 4
label.setText('ABCdeFGh\nIJK\nLmnO')
label.fontName = "Helvetica-Bold"
label.fontSize = 20
label.width = 110
label.height = 70
d.add(label)
# this saves d as a pdf
renderPDF.drawToFile(d, mypdf, 'What\'s this?')
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020