Super cool to see the progress IntelliCAD has made with their C++ API. I’ve been working to port pyrx, still not released, there’s a couple small issues I need to work out
import traceback
from pyrx import Ap, Db, Ge
# -----------------------------
# Simple spline-based vector font
# -----------------------------
FONT = {
"H": [[(0, 0), (0, 10)], [(5, 0), (5, 10)], [(0, 5), (5, 5)]],
"A": [[(0, 0), (2.5, 10), (5, 0)], [(1.2, 5), (3.8, 5)]],
"P": [[(0, 0), (0, 10)], [(0, 10), (5, 9), (5, 6), (0, 5)]],
"Y": [[(0, 10), (2.5, 5)], [(5, 10), (2.5, 5)], [(2.5, 5), (2.5, 0)]],
"N": [[(0, 0), (0, 10)], [(0, 10), (5, 0)], [(5, 0), (5, 10)]],
"E": [[(5, 0), (0, 0), (0, 10), (5, 10)], [(0, 5), (4, 5)]],
"W": [[(0, 10), (1.2, 0), (2.5, 6), (3.8, 0), (5, 10)]],
"R": [[(0, 0), (0, 10)], [(0, 10), (5, 9), (5, 6), (0, 5)], [(0, 5), (5, 0)]],
" ": [],
}
# -----------------------------
# Create a spline from points
# -----------------------------
def add_spline(ms, pts, base, scale):
arr = []
for p in pts:
arr.append(Ge.Point3d(base.x + p[0] * scale, base.y + p[1] * scale, 0.0))
spline = Db.Spline(arr, 3, 0.0)
ms.appendAcDbEntity(spline)
# -----------------------------
# Write text as splines
# -----------------------------
def write_happy_new_year(start=Ge.Point3d(0, 0, 0), scale=5.0, spacing=8.0):
db = Db.curDb()
ms = Db.BlockTableRecord(db.modelSpaceId(), Db.OpenMode.kForWrite)
cursor = Ge.Point3d(start.x, start.y, 0)
text = "HAPPY NEW YEAR"
for ch in text:
strokes = FONT.get(ch.upper(), [])
for stroke in strokes:
add_spline(ms, stroke, cursor, scale)
cursor.x += spacing * scale
# -----------------------------
# Entry point
# -----------------------------
def PyRxCmd_HAPPYNEWYEAR():
try:
write_happy_new_year(start=Ge.Point3d(0, 0, 0), scale=2.5, spacing=7.0)
except Exception as err:
traceback.print_exception(err)