Replies: 2 comments 5 replies
-
|
The question is not clear to me in what you have tried, or how you are generating your field code. here’s a quick example using import traceback
from pyrx import Ap, Db, Ed, Ge
def make_field(db: Db.Database, id: Db.ObjectId, pnt : Ge.Point3d):
mtext = Db.MText()
mtext.setLocation(pnt)
model = Db.BlockTableRecord(db.modelSpaceId(), Db.OpenMode.kForWrite)
model.appendAcDbEntity(mtext)
expr = '%<\\AcObjProp Object(%<\\_ObjId {}>%).Length \\f "%lu6">%'.format(id.asOldId())
field = Db.Field(expr, True)
mtext.setField(field)
@Ap.Command()
def doit1():
try:
db = Db.curDb()
ps, id, pnt = Ed.Editor.entSel("\nSelect: ", Db.Line.desc())
if ps != Ed.PromptStatus.eOk:
raise RuntimeError("oof")
make_field(db,id,pnt)
Db.Core.evaluateFields()
except Exception:
print(traceback.format_exc()) |
Beta Was this translation helpful? Give feedback.
4 replies
-
|
It looks like I’m missing a function in AcDbField. An alternate method of creating nested fields is to use children. Acad::ErrorStatus setFieldCode(
const ACHAR* pszFieldCode,
AcDbField::FieldCodeFlag nFlag = (AcDbField::FieldCodeFlag) 0,
AcDbFieldArray* pChildFields = NULL
);I'll add a wrapper for it |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How do I achieve this effect from PyRx? ZWCAD calculates the field value, without evaluation, correctly, but AutoCAD inserts
###Beta Was this translation helpful? Give feedback.
All reactions