Example for creating 3d objects with Phyton
Is there a reference for creating 3d objects with phyton, e.g. a box. I have only found examples for data extraction (with the exception of solutions with external classes/libraries). There is hardly anything to be found in the bricscad manual or the developer appendix.
0
Comments
-
If its primitive solids, like a box then you could just make a front end and use the Bricscad commands to make a box, draw a rectang then extrude. Solids are ACIS models and extremely complex to make from a code only point of view. Same with Union Subtract etc use commands. Can use lisp or Python.
This is like 1/2 a simple box details.
PICK((-1 . <Entity name: a9005250>) (0 . "3DSOLID") (5 . "1030") (330 . <Entity name: b90f3e30>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbModelerGeometry") (70 . 1) (1 . "700 0 1 0 ") (1 . "@33 Open Design Alliance ACIS Builder @14 ACIS 34.0.1 NT @24 Fri May 9 12:13:59 2025 ") (1 . "1 9.9999999999999995e-007 1e-010 ") (1 . "body $-1 -1 $-1 $1 $-1 $-1 #") (1 . "lump $-1 -1 $-1 $-1 $2 $0 #") (1 . "shell $-1 -1 $-1 $-1 $-1 $3 $-1 $1 #") (1 . "face $-1 -1 $-1 $4 $5 $2 $-1 $6 forward single #") (1 . "face $-1 -1 $-1 $7 $8 $2 $-1 $9 forward single #") (1 . "loop $-1 -1 $-1 $-1 $10 $3 #") (1 . "plane-surface $-1 -1 $-1 11.953916676017656 5.3596719492582343 0 0 1 0 -1 0 0 forward_v I I I I #") (1 . "face $-1 -1 $-1 $11 $12 $2 $-1 $13 forward single #") (1 . "loop $-1 -1 $-1 $-1 $14 $4 #") (1 . "plane-surface $-1 -1 $-1 14.239741114912514 4.2052923831273867 0 1 0 0 0 1 0 forward_v I I I I #") (1 . "coedge $-1 -1 $-1 $15 $16 $17 $18 forward $5 $-1 #") (1 . "face $-1 -1 $-1 $19 $20 $2 $-1 $21 forward single #") (1 . "loop $-1 -1 $-1 $-1 $22 $7 #") (1 . "plane-surface $-1 -1 $-1 11.953916676017656 3.0509128169965387 0 0 -1 0 1 0 0 forward_v I I I I #") (1 . "coedge $-1 -1 $-1 $23 $24 $25 $26 forward $8 $-1 #") (1 . "coedge $-1 -1 $-1 $27 $10 $24 $28 reversed $5 $-1 #") (1 . "coedge $-1 -1 $-1 $10 $27 $29 $30 forward $5 $-1 #") (1 . "coedge $-1 -1 $-1 $31 $25 $10 $18 reversed $32 $-1 #") (1 . "edge $-1 -1 $-1 $33 0 $34 4.5716488777897162 $10 $35 forward @7 unknown #") (1 . "face $-1 -1 $-1 $36 $32 $2 $-1 $37 reversed single #") (1 . "loop $-1 -1 $-1 $-1 $38 $11 #") (1 . "plane-surface $-1 -1 $-1 9.6680922371227975 4.2052923831273867 0 -1 0 0 0 -1 0 forward_v I I I I #") (1 . "coedge $-1 -1 $-1 $39 $40 $41 $42 forward $12 $-1 #") (1 . "coedge $-1 -1 $-1 $43 $14 $40 $44 reversed $8 $-1 #") (1 . "coedge $-1 -1 $-1 $14 $43 $15 $28 forward $8 $-1 #") (1 . "coedge $-1 -1 $-1 $17 $41 $14 $26 reversed $32 $-1 #") (1 . "edge $-1 -1 $-1 $34 0 $45 2.3087591322616956 $14 $46 forward @7 unknown #") (1 . "coedge $-1 -1 $-1 $16 $15 $47 $48 reversed $5 $-1 #") (1 . "edge $-1 -1 $-1 $49 0 $34 50 $24 $50 forward @7 unknown #") (1 . "coedge $-1 -1 $-1 $51 $38 $16 $30 reversed $20 $-1 #") (1 . "edge $-1 -1 $-1 $52 0 $33 50 $16 $53 forward @7 unknown #") (1 . "coedge $-1 -1 $-1 $41 $17 $38 $54 reversed $32 $-1 #") (1 . "loop $-1 -1 $-1 $-1 $17 $19 #") (1 . "vertex $-1 -1 $-1 $30 $55 #") (1 . "vertex $-1 -1 $-1 $28 $56 #") (1 . "straight-curve $-1 -1 $-1 9.6680922371227975 5.3596719492582343 50 1 0 0 I I #") (1 . "face $-1 -1 $-1 $-1 $57 $2 $-1 $58 forward single #") (1 . "plane-surface $-1 -1 $-1 11.953916676017657 4.2052923831273867 50 0 0 -1 1 0 0 reverse_v I I I I #") (1 .0 -
you might have a look at https://github.com/CEXT-Dan/PyRx and see if it is a fit for your workflow. It’s not directly supported by Bricsys, so there’s that caveat
here’s a couple example:
from pyrx import Rx, Ge, Gi, Db, Ap, Ed, Aximport traceback# ActiveX style@Ap.Command()def doitx():try:ps, pnt = Ed.Editor.getPoint("\nPick a point: ")if ps != Ed.PromptStatus.eNormal:raise RuntimeError("Oops {}: ".format(ps))axApp = Ap.Application.acadApplication()axDoc = axApp.activeDocument()axSpace = axDoc.modelSpace()axSolid = axSpace.addBox(pnt,10,10,10)axSolid.setLayer("0")except Exception as err:traceback.print_exception(err)# BRX style@Ap.Command()def doitbrx():try:ps, pnt = Ed.Editor.getPoint("\nPick a point: ")if ps != Ed.PromptStatus.eNormal:raise RuntimeError("Oops {}: ".format(ps))db = Db.curDb()solid = Db.Solid3d()solid.setDatabaseDefaults(db)solid.createBox(10,10,10)solidId = db.addToCurrentspace(solid)solid.transformBy(Ge.Matrix3d.translation(pnt - Ge.Point3d.kOrigin))except Exception as err:traceback.print_exception(err)
0 -
Thank you ALANH and Its_Alive. I have tried with the code examples and a bit with python, scripteditor, lisp, activx, grasshopper. I use Bricscad on MAC and WIN. So there are one possibilitie left. I have created the geometries now with c-code as cross compiled standalone program. If brics-python would do this for me with less effort out of the box and a better documentation, i would try it in this way again. Nevertheless it is impressiv what could be done with python.0