Leaderboard
Popular Content
Showing content with the highest reputation on 04/18/2025 in all areas
-
Hi Something like This? (defun c:GLVScopi (/ cj cj1 n e mx my) (if (setq cj (ssget '((0 . "*TEXT")))) (progn (setq cj1 (ssadd)) (while (setq e (ssname cj (setq n (if n (1+ n) 0)))) (setq tx (cdr (assoc 1 (setq l (entget e)))) mx (if mx (min (cadr (assoc 10 l)) mx) (cadr (assoc 10 l))) my (if my (min (caddr (assoc 10 l)) my) (caddr (assoc 10 l))) ) (entmake (subst (cons 1 (strcat (chr (+ (ascii (substr tx 1 1)) 1)) (substr tx 2))) (assoc 1 l) l)) (ssadd (entlast) cj1) ) (command "_move" cj1 "" (list mx my)) ) ) (princ) )2 points
-
from pyrx import Rx, Ge, Gi, Gs, Db, Ap, Ed, Ax import traceback import wx # wxPython import openpyxl as xl from openpyxl.drawing.image import Image as xlImage from openpyxl.utils.cell import get_column_letter @Ap.Command() def doit(): try: db = Db.curDb() ps, id, _ = Ed.Editor.entSel("\nSelect a table: ", Db.Table.desc()) if ps != Ed.PromptStatus.eOk: raise RuntimeError("Selection Error! {}: ".format(ps)) wb = xl.Workbook() ws = wb.active table = Db.Table(id) opts = Db.TableIteratorOption.kTableIteratorSkipMerged for cell in table.cells(opts): if table.cellType(cell.row, cell.column) == Db.CellType.kBlockCell: blk = table.blockTableRecordId(cell.row, cell.column) img: wx.Image = Gs.Core.getBlockImage(blk, 64, 64, 1.0, [0, 0, 0]) img.SetMaskColour(0, 0, 0) img.SetMask(True) imgpath = "E:\\temp\\Icons\\{}.png".format(blk.handle()) img.SaveFile(imgpath, wx.BITMAP_TYPE_PNG) xlimg = xlImage(imgpath) xlimg.width = 64 xlimg.height = 64 cellref = "{}{}".format(get_column_letter(cell.column + 1), cell.row + 1) ws.add_image(xlimg, cellref) else: ws.cell( row=cell.row + 1, column=cell.column + 1, value=table.textString(cell.row, cell.column), ) wb.save("E:\\temp\\logo.xlsx") except Exception as err: traceback.print_exception(err)1 point
-
Lisp functions take a resbuf argument. A resbuf in python is a list of tuples Each tuple (Typed value) has a data type and a value, you can also use integers as ARX does Rx.LispType: kAngle kDottedPair kDouble kInt16 kInt32 kListBegin kListEnd kNil kNone kObjectId kOrientation kPoint2d kVector2d kPoint3d kVector3d kT_atom kText kVoid kSelectionSet you can also use integers as ARX does #define RTNONE 5000 /* No result */ #define RTREAL 5001 /*Real number */ #define RTPOINT 5002 /* 2D point X and Y only */ #define RTSHORT 5003 /* Short integer */ #define RTANG 5004 /* Angle */ #define RTSTR 5005 /* String */ #define RTENAME 5006 /* Entity name */ #define RTPICKS 5007 /* Pick set */ #define RTORINT 5008 /* Orientation */ #define RT3DPOINT 5009 /* 3D point - X, Y, and Z */ #define RTLONG 5010 /* Long integer */ #define RTVOID 5014 /* Blank symbol */ #define RTLB 5016 /* list begin */ #define RTLE 5017 /* list end */ #define RTDOTE 5018 /* dotted pair */ #define RTNIL 5019 /* nil */ #define RTT 5021 /* T atom */ #define RTMODELESS 5027 /* interrupted by modeless dialog */1 point
-
Not sure the difference between “parametric blocks” and “dynamic blocks” from an API perspective. We’ll have to keep an eye on that1 point
-
O.K....... forgot about it... I changed the py function file name but didn't changed it in "loadPythonModule" string ... now it is this way with the correct file name (Py_tablewithimagetoexcel.py): from pyrx import Ap Ap.Application.loadPythonModule("C:\\Users\\Aridzv\\AppData\\Roaming\\Bricsys\\BricsCAD\\Lsp\\Python\\Py_tablewithimagetoexcel.py") now it's working and no need for the calls from "on_start.lsp" and "on_doc_load.lsp" . thanks!!1 point
-
"on_start.lsp" and "on_doc_load.lsp" may load in to BricsCAD at a different time then PyRx. If it’s loaded before PyRx, there is no pyload command It’s why pyrx_onload.py was created But if what you have is working for you, then, yay1 point
-
(defun c:GLVScopi (/ cj cj1 n e mx my para) (if (setq cj (ssget '((0 . "*TEXT")))) (while (not para) (setq cj1 (ssadd)) (while (setq e (ssname cj (setq n (if n (1+ n) 0)))) (setq tx (cdr (assoc 1 (setq l (entget e)))) mx (if mx (min (cadr (assoc 10 l)) mx) (cadr (assoc 10 l))) my (if my (min (caddr (assoc 10 l)) my) (caddr (assoc 10 l))) ) (entmake (subst (cons 1 (strcat (chr (+ (ascii (substr tx 1 1)) 1)) (substr tx 2))) (assoc 1 l) l)) (ssadd (entlast) cj1) ) (command "_move" cj1 "" (list mx my)) (setq cj cj1 cj1 nil n nil mx nil my nil) ) ) (princ) ) @Ish I edited it from my smartphone, so I couldn't test it. Check it yourself if it works.1 point
-
maybe a useful example, check if two curves overlap the lisp: (defun c:doit (/ c1 c2) (setq c1 (car (entsel "pick curve 1\n"))) (setq c2 (car (entsel "pick curve 2\n"))) (check_overlap c1 c2) ) the python from pyrx import Rx, Ge, Gi, Gs, Db, Ap, Ed, Ax import traceback @Ap.LispFunction() def check_overlap(resbuf): try: cv1 = None cv2 = None # check the resbuf if len(resbuf) != 2: return None if resbuf[0][0] != Rx.LispType.kObjectId: return None if resbuf[1][0] != Rx.LispType.kObjectId: return None # get the geometry dbc1 = Db.Curve(resbuf[0][1]) cv1 = dbc1.getAcGeCurve() dbc2 = Db.Curve(resbuf[1][1]) cv2 = dbc2.getAcGeCurve() # do the check cc = Ge.CurveCurveInt3d(cv1, cv2) return cc.overlapCount() > 0 except Exception as err: traceback.print_exception(err) and the results1 point
-
Create a lisp function by using the “@Ap.LispFunction()” example from pyrx import Rx, Ge, Gi, Gs, Db, Ap, Ed, Ax import traceback @Ap.LispFunction() def lfunc(resbuf): try: #iterate the resbuf for type, value in resbuf: print(type, value) return resbuf except Exception as err: traceback.print_exception(err)1 point
-
Hi @Danielm103 what I was asking that I used lisp to write a defun command name that loads the correct dvb then runs the correct module. I want the equivalent to the 2 line answer, you already have python code saved but not loaded. The python arx is preloaded on start up. Say what you would put in a menu button, Ribbon etc.1 point
-
If you are not using dynamic blocks, then you don’t need the effective name, if you do than the function getEffectiveNameFromBtrId is fine, it's actually the same thing I'll be adding I make one about once per week. Otherwise, you will need to create a GitHub account and watch the project1 point
-
Sorry, I noticed your running BricsCAD 2021? If so, I’m sorry to say only v24-v25 is supported. Or maybe you forgot to update your profile? 1, head over to https://github.com/CEXT-Dan/PyRx?tab=readme-ov-file#installation and have look at the project 2, Download and install 3.12.10 x64 from https://www.python.org/downloads/windows/ (all users is NOT checked, and PATH is checked) 3, Open up PowerShell and type “pip install cad-pyrx” without the quotes. 4, in BricsCAD, type “appload”, navigate to: “AppData\Programs\Python\Python312\Lib\site-packages\pyrx\RxLoaderV25.0.brx” 5, Make sure it’s loaded, type “pyload” at the bricscad prompt 6, if the load dialog box shows, then were successful so far 7, close bricscad 8, back in powershell type “pip install openpyxl” , this will install the excel library. 9, copy paste the sample code above into a file into a text file, “myfirstmodule.py” 10, using a text editor, edit the paths in the sample, maybe rename the “doit” command 11, open BricsCAD, type in “pyload”, load your module, run your new command If you get this far, you might want to grab a python editor like VsCode and install the python plugins1 point
-
See if you're happy with this command cptib for Copy-Paste-Text-Increase-Beginletter I assume 1 beginletter gets increased. ;; https://www.cadtutor.net/forum/topic/18257-entmake-functions/ ;; draw a TEXT (defun drawText (pt hgt str) (entmakex (list (cons 0 "TEXT") (cons 10 pt) (cons 40 hgt) (cons 1 str)))) ;; Copy-Paste-Text-Increase-Beginletter (defun c:cptib ( / i ss ent p2 ang_ dist_ val ip ht char newval) (princ "\nSelect Text entities: ") (setq ss (ssget (list (cons 0 "TEXT")) )) (setq i 0) (repeat (sslength ss) (setq ent (ssname ss i)) ;; get the properties of the entity. Contents, insertpoint, text height. If needed we could add layer, rotation... (setq val (cdr (assoc 1 (entget ent)))) (setq ip (cdr (assoc 10 (entget ent)))) (setq ht (cdr (assoc 40 (entget ent)))) (if (= i 0) (progn (setq p2 (getpoint ip "\nPaste to point 2: ")) (setq ang_ (angle ip p2 )) (setq dist_ (distance ip p2 )) ) ) (setq char (ascii (substr val 1 1))) ;; gets the first character, then convert it to the ASCII number (setq newval (strcat (chr (+ 1 char)) (substr val 2) )) ;; make a new value: ASCII increased with 1, put back as a character, then add the rest of the old value (drawText (polar ip ang_ dist_) ht newval) (setq i (+ i 1)) ) (princ) ) ...1 point