All Activity
- Past hour
- 
	@devitg sample dwg upload for reference @GLAVCVS It doesn't function correctly, possibly due to the Clock or counter clock direction. mb.dwg
- Today
- 
	SelectionSet class methods class SelectionSet: def add(self, id: Db.ObjectId, /) -> None: ... def adsname(self, /) -> Db.AdsName: ... def clear(self, /) -> None: ... def hasMember(self, id: Db.ObjectId, /) -> bool: ... def objectIdArray(self, desc: Rx.RxClass = Db.Entity, /) -> Db.ObjectIdArray: ... def objectIds(self, desc: Rx.RxClass = Db.Entity, /) -> list[Db.ObjectId]: ... def remove(self, id: Db.ObjectId, /) -> None: ... def size(self, /) -> int: ... def ssNameX(self, val: int = 0, /) -> list: ... def ssSetFirst(self, /) -> bool: ... def ssXform(self, xform: Ge.Matrix3d, /) -> Ed.PromptStatus: ... def toList(self, /) -> list[Db.ObjectId]: ... Note, ObjectIdArray is basically the same as list[Db.ObjectId], but the memory is allocated in C++ instead of Python. There may be performance reasons to choose one of the the other, but for now, they can be used interchangeably
- 
	Lets say we want only lines and arcs, but still want to use AcDbCurve class, pass a list of descriptions # returns a PromptStatus and a SelectionSet class ps, ss = Ed.Editor.select([(8, "0")]) if ps != Ed.PromptStatus.eOk: raise RuntimeError("Selection Error! {}: ".format(ps)) curves = [Db.Curve(id) for id in ss.objectIds([Db.Line.desc(),Db.Arc.desc()])] for curve in curves: print(curve.getDistAtParam(curve.getEndParam()))
- 
	Support derived types, Lets say you want to get all the objects in the set that are derived from AcDbCurve, to do some sort of base class operation (AcDb2dPolyline, AcDb3dPolyline, AcDbArc, AcDbCircle, AcDbEllipse, AcDbLeader, AcDbLine, AcDbPolyline, AcDbRay, AcDbSpline, AcDbXline) # returns a PromptStatus and a SelectionSet class ps, ss = Ed.Editor.select([(8, "0")]) if ps != Ed.PromptStatus.eOk: raise RuntimeError("Selection Error! {}: ".format(ps)) curves = [Db.Curve(id) for id in ss.objectIds(Db.Curve.desc())] for curve in curves: print(curve.getDistAtParam(curve.getEndParam()))
- 
	The real power is post filtering entity types, for example, we want the selection set to filter the visual selection set on screen, but then we want to separate out objects by type. SelectionSet.objectIds() method is overloaded to take an entity class description and returns the types that match. it does not open the object, so it’s extremely fast #returns a PromptStatus and a SelectionSet class ps, ss = Ed.Editor.select([(0, "TEXT,LWPOLYLINE,LINE")]) if ps != Ed.PromptStatus.eOk: raise RuntimeError("Selection Error! {}: ".format(ps)) # create a list of entites ant are opened for read texts = [Db.Text(id) for id in ss.objectIds(Db.Text.desc())] lines = [Db.Line(id) for id in ss.objectIds(Db.Line.desc())] plines = [Db.Polyline(id) for id in ss.objectIds(Db.Polyline.desc())] for text in texts: pass # do something for line in lines: pass # do something for pline in plines: pass # do something
- 
	The SelectionSet class is an enumerable collection of ObjectIds, example #returns a PromptStatus and a SelectionSet class ps, ss = Ed.Editor.select() for id in ss: ent = Db.Entity(id) print(ent.isA().dxfName())
- 
	SelectionSet filters can also be inline Ed.Editor.select([(0, "TEXT,LWPOLYLINE,LINE")])
- 
	Danielm103 started following Selection sets in Python.
- 
	Filters Instead of creating a dedicated ResultBuffer class like in .NET, I decided to build a wrapper for Python’s built in types. Throughout the API, resbuf* or ResultBuffer are simply a list of tuples, in the format of a group code and a value typedValues = [(TYPE, VALUE)] Depending on the context the group code may be a Lisp type code, or in the case of selection sets, DXF codes. Here are two possible formats # long format filter = [ (Db.DxfCode.kDxfStart, "TEXT,LWPOLYLINE,LINE"), (Db.DxfCode.kDxfOperator, "<OR"), (Db.DxfCode.kDxfLayerName, "0"), (Db.DxfCode.kDxfLayerName, "8"), (Db.DxfCode.kDxfOperator, "OR>"), ] # short format filter = [ (0, "TEXT,LWPOLYLINE,LINE"), (-4, "<OR"), (8, "Layer1"), (8, "Layer2"), (8, "Layer3"), (-4, "OR>"), ]
- 
	Dhelviayk joined the community
- 
	mhupp started following Help me create a annotative dimension style and text style style
- 
	annotative text style Help me create a annotative dimension style and text style stylemhupp replied to sachindkini's topic in AutoLISP, Visual LISP & DCL Entmake text style. (entmake '((0 . "STYLE") (100 . "AcDbSymbolTableRecord") (100 . "AcDbTextStyleTableRecord") (2 . "style name here") (70 . 0) (40 . 0.0) (41 . 1.0) (50 . 0.0) (71 . 0) (42 . 1.0) (3 . "Arial.ttf") (4 . "") ) ) use setvar for dimstyles nothing will be outputted to command prompt. (setvar 'DIMADEC 2) (setvar 'DIMALT "off") I think @Steven P has dug into this more.
- Yesterday
- 
	  AUTOLISP FIELD AREA FOR PL BUGBIGAL replied to Gabriel Paixão's topic in AutoLISP, Visual LISP & DCL Also this as mentioned. (setq ent (entget (car (entsel "\nPick an object for layer name ")))) (setq MyLayerName (cdr (assoc 8 ent))) (setq allPolylines (ssget "_X" (list (0 . "*POLYLINE")(cons 8 MyLayerName))))
- 
	  annotative text style Help me create a annotative dimension style and text style styleBIGAL replied to sachindkini's topic in AutoLISP, Visual LISP & DCL I think you need to look at Entmake a style whether its a text style or a dimension style rather than trying to override current settings. trying to find a good simple example some else may have one.
- 
	Steven P started following AUTOLISP FIELD AREA FOR PL BUG
- 
	AUTOLISP FIELD AREA FOR PL BUGSteven P replied to Gabriel Paixão's topic in AutoLISP, Visual LISP & DCL If it was me I would allow the user to select an entity on the layer rather than typing it in, or use something like BigAls multi getvals to select the layer from a list - saves typing errors. You can add to filters in the selection set: (setq allPolylines (ssget "_X" (list (0 . "*POLYLINE")(cons 8 MyLayerName)))) Note here that list is used if you want any of the filters to be programmatically. 'cons' used to construct the list and MyLayerName is a variable you might want to work out earlier in the LISP. Lee Mac has a very good explanation on his website for ssget. You can loop through your selection set and perhaps this snippet will help: ;;https://www.cadtutor.net/forum/topic/66091-centre-of-hatch/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:CtrCoo (/ findctr a apt) ;;Center point of a hatch or a rectangle (defun findctr (en / pt) (command "_.Zoom" "_Object" en "") (setq pt (getvar 'viewctr)) (command "_.Zoom" "_Previous") pt ) (setq a (car (entsel "Select Rectangle: : ")) apt (findctr a) ) (command "_Text" "_Justify" "_MC" apt 0.1 0 apt) (princ) ) Copy FindCtr and use that to get the centre point of each object, using that as the insert point for the mtext. Maybe this will help you along?
- 
	symoin started following Lisp for to get y value of police based on datum value and line.
- 
	Lisp for to get y value of police based on datum value and line.symoin replied to Ish's topic in AutoLISP, Visual LISP & DCL hi This is a very good lisp, can this be still upgraded to show the station of the selected lines also, at a certain distance south. like 20 or something.
- 
	The result looks geometrically perfect I also started writing something on Friday with a similar approach. I'll post it when I finish it.
- 
	The result looks geometrically perfect I also started writing something on Friday with a similar approach. I'll post it when I finish it.
- 
	GP_ started following Hybrid parallel
- 
	
- 
	
- 
	sachindkini started following Help me create a annotative dimension style and text style style
- 
	  annotative text style Help me create a annotative dimension style and text style stylesachindkini posted a topic in AutoLISP, Visual LISP & DCL Dear All, im trying create a annotative dimension style and text style style . annotation text style link to annotation dimstyle . create text style and dimethyl but annotative symbole not shown in dimension style and also text style )DIM-100 & DIM-200 is annotative dimension style) (defun c:TEST () (setvar "cmdecho" 0) (setvar "expert" 0) (command "undo" "be") (princ "\nFunction: Quickly create new dimension styles.\n") (if (not (tblsearch "STYLE" "STANDARD")) (command "style" "Standard" "txt" "" "1" "" "" "") ) (if (not (tblsearch "STYLE" "STANDARD")) (command ".-style" "STANDARD" "TXT" "0" "1" "0" "N" "N" "N") ) (command "dimadec" "2" "dimalt" "off" "dimalttz" "1" "dimaltu" "2" "dimassoc" "2" "dimasz" "1" "dimatfit" "3" "dimaunit" "0" "dimazin" "0" "dimblk" "_ARCHTICK" "dimcen" "0" "dimclrd" "0" "dimclre" "0" "dimclrt" "0" "dimdec" "2" "dimdle" "0.00" "dimdli" "0.05" "dimdsep" "." "dimexe" "0.35" "dimexo" "0.35" "dimfxlon" "off" "dimgap" "0.5" "dimjust" "0" "dimldrblk" "_ARCHTICK" "dimlfac" "1" "dimlunit" "2" "dimscale" "1" "dimtad" "1" "dimtdec" "2" "dimtfac" "1" "dimtfill" "0" "dimtfillclr" "0" "dimtih" "off" "dimtix" "off" "dimtmove" "0" "dimtofl" "on" "dimtol" "off" "dimtolj" "1" "dimtxsty" "Standard" "dimtxt" "2.5" "dimtzin" "1" "dimupt" "off" "dimzin" "1" ) (if (not (tblsearch "dimstyle" "TEST-123")) (command "dimstyle" "S" "TEST-123") ) ;; -------------------------------------- (if (not (tblsearch "STYLE" "TEST-100")) (command ".-style" "TEST-100" "Calibri" "0" "1" "0" "N" "N" "N") ) (setvar "DIMTOL" 1) (setvar "DIMTM" 0.05) (setvar "DIMTP" 0.05) (setvar "DIMTXSTY" "TEST-100") ;; Create or update dimension style (if (not (tblsearch "dimstyle" "DIM-100")) (progn (command ".-dimstyle" "S" "DIM-100") ) (command ".-dimstyle" "R" "DIM-100") ) ;; -------------------------------------- (if (not (tblsearch "STYLE" "TEST-200")) (command ".-style" "TEST-200" "ARIAL" "0" "1" "0" "N" "N" "N") ) (setvar "DIMTOL" 1) (setvar "DIMTM" 0.10) (setvar "DIMTP" 0.10) (setvar "DIMTXSTY" "TEST-200") (if (not (tblsearch "dimstyle" "DIM-200")) (progn (command ".-dimstyle" "S" "DIM-200") ) (command ".-dimstyle" "R" "DIM-200") ) (command "undo" "e") (alert "\nPrompt:\nDimension style creation completed!\n") (princ) ) OPT-2 THIS OPTION TEXT STYLE NOT CRETED IN ANNOTATIVE STYLE AND ONE MORE QUERT I WANT TEST-123 IS NORMAL DIM STYLE (defun c:TEST (/ oldcmdecho oldexpert) (setq oldcmdecho (getvar "cmdecho") oldexpert (getvar "expert")) (setvar "cmdecho" 0) (setvar "expert" 5) (command "_.undo" "_begin") (if (not (tblsearch "STYLE" "Standard")) (command "_.-style" "Standard" "txt" "2.5" "" "" "" "") ) (if (not (tblsearch "STYLE" "TEST-100")) (command "_.-style" "TEST-100" "Calibri" "2.5" "" "" "" "") ) (if (not (tblsearch "STYLE" "TEST-200")) (command "_.-style" "TEST-200" "Arial" "2.5" "" "" "" "") ) (while (> (getvar "cmdactive") 0) (command "")) (if (not (tblsearch "DIMSTYLE" "TEST-123")) (progn (setvar "DIMTOL" 0) (setvar "DIMTXSTY" "Standard") (command "_.-dimstyle" "_S" "TEST-123") (while (> (getvar "cmdactive") 0) (command "")) ) ) (if (not (tblsearch "DIMSTYLE" "DIM-100")) (progn (setvar "DIMTOL" 1) (setvar "DIMTM" 0.05) (setvar "DIMTP" 0.05) (setvar "DIMTXSTY" "TEST-100") (setvar "DIMTDEC" 2) (command "_.-dimstyle" "_S" "DIM-100") (while (> (getvar "cmdactive") 0) (command "")) ) ) ;; DIM-200 - With tolerances (if (not (tblsearch "DIMSTYLE" "DIM-200")) (progn (setvar "DIMTOL" 1) (setvar "DIMTM" 0.10) (setvar "DIMTP" 0.10) (setvar "DIMTXSTY" "TEST-200") (setvar "DIMTDEC" 2) (command "_.-dimstyle" "_S" "DIM-200") (while (> (getvar "cmdactive") 0) (command "")) ) ) (command "_.undo" "_end") (setvar "cmdecho" oldcmdecho) (setvar "expert" oldexpert) (princ "\nTEST command completed successfully!") (princ) )
- 
	This is kind of close, I split each line into some number of segments, then use closest point. Simplify reduces the number of segments, but changes the precision. Not sure if you can do this in lisp import traceback from pyrx import Db, Ed, Ge, Ap, Rx, Gs @Ap.Command() def centline(): try: ps1, id1, _ = Ed.Editor.entSel("\nPick 1") ps2, id2, _ = Ed.Editor.entSel("\nPick 2") pl1 = Db.Polyline(id1) pl2 = Db.Polyline(id2) crv1 = pl1.getAcGeCurve() crv2 = pl2.getAcGeCurve() # 200 can be a function of lenth, both must be the same smp1, _ = crv1.getSamplePoints(100) smp2, _ = crv2.getSamplePoints(100) spl1 = pl1.getSplitCurves(smp1) spl2 = pl2.getSplitCurves(smp2) pnts = [] for l, r in zip(spl1, spl2): cl = l.getAcGeCurve() cr = r.getAcGeCurve() poc1, poc2 = cl.getClosestPointsTo(cr) p1 = poc1.point3d() p2 = poc2.point3d() pnts.append(p1 + (p2 - p1) * 0.5) db = Db.curDb() cs = db.currentSpace(Db.OpenMode.kForWrite) npl = Db.Polyline(pnts) npl.simplify(0.01) npl.setLayer("0") npl.setColor(1) cs.appendAcDbEntity(npl) except Exception as err: traceback.print_exception(err) drawing AxisExample_dan.dwg
- 
	wobo joined the community
- 
	menakerelous joined the community
- 
	adel ahmed hagras joined the community
- 
	Saxlle started following Extract Polyline Lengths with Associated Text Labels in AutoCAD
- 
	Extract Polyline Lengths with Associated Text Labels in AutoCADSaxlle replied to Tamim's topic in AutoLISP, Visual LISP & DCL @Tamim Try this code and see if it helpful: (prompt "\nTo run a LISP type: LPL") (princ) (defun c:LPL ( / ss len circ txt_height lst i minPt maxPt midPt circle inc ang num ptlist k pt ssn pl_len ins_pt) (prompt "\nSelect all TEXT entities:\n") (setq ss (ssget (list (cons 0 "TEXT"))) len (sslength ss) circ 0.05 ;; radius of the circle can be changeable txt_height 0.01 ;; mtext height can be changeable lst (list) i 0 ) (while (< i len) (vla-GetBoundingBox (vlax-ename->vla-object (ssname ss i)) 'minPt 'maxPt) (setq minPt (vlax-safearray->list minPt) maxPt (vlax-safearray->list maxPt) midPt (mapcar '* (mapcar '+ minPt maxPt) (list 0.5 0.5)) ) (entmake (list (cons 0 "CIRCLE") (cons 100 "AcDbEntity") (cons 100 "AcDbCircle") (cons 8 (getvar 'clayer)) (cons 10 midpt) (cons 40 circ))) (setq circle (entlast) inc 0.25 ang 0 num (fix (/ (* pi 2) inc)) ptlist (list) k 0 ) (repeat num (setq pt (polar midPt ang circ) ptlist (append (list pt) ptlist) ang (+ ang inc) ) ) (setq ssn (ssget "_F" ptlist (list (cons 0 "LWPOLYLINE"))) pl_len (getpropertyvalue (ssname ssn k) "Length") ) (entdel circle) (setq lst (cons (list (cdr (assoc 1 (entget (ssname ss i)))) "\t " (rtos pl_len 2 3) "\\P") lst) i (1+ i) ) ) (setq lst (vl-sort lst (function (lambda (x e) (< (atoi (substr (car x) 3 (strlen (car x)))) (atoi (substr (car e) 3 (strlen (car e)))))))) lst (cons (list "\\fArial|b0|i0|c0|p34;S.No\tLength Ft\\P") lst) ins_pt (getpoint "\nPick the insertation point:") ) (entmake (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (cons 8 (getvar 'clayer)) (cons 10 ins_pt) (cons 40 txt_height) (cons 72 1) (cons 1 (apply 'strcat (mapcar '(lambda (x) (apply 'strcat x)) lst))))) (prompt "\nThe labels and the length of the polylines were added as MTEXT!") (princ) ) Also, you can see the short video example of how it works. LengthPolylineMtext.mp4 Best regards.
- 
	Thanks @Danielm103 That seems pretty accurate, although geometrically massive. It seems like there are a lot of points that aren't necessary. I guess something elegant should be only what's geometrically necessary. But I wonder what the result looks like when the geometry of the reference polylines is more extensive and varied.
- 
	Danielm103 started following Hybrid parallel
- 
	Shapley or geopandas can create this, there’s artifacts though. The algorithm is some sort of Voronoi https://centerline.readthedocs.io/en/latest/# https://gis.stackexchange.com/questions/474810/how-to-get-the-centerline-of-a-polygon-without-artefacts-in-python a bit wonky
- Last week
- 
	No, the program is required to define the reactors used to update the textbox position.
- 
	  Python, Extract Polyline Lengths with Associated Text Labels in AutoCADDanielm103 replied to Danielm103's topic in .NET, ObjectARX & VBA I used a similar approach here, the user wanted to set the elevation of the contour lines to the nearest label. This is where KD-Trees really start to shine as they can handle millions of points, with millions of searches
- 
	  Python, Extract Polyline Lengths with Associated Text Labels in AutoCADDanielm103 replied to Danielm103's topic in .NET, ObjectARX & VBA Yeah, I chose to search for the closest polyline to the text. BricsCAD has ssget crossing circle , (ssget "CC" point1 point2), could be similar to a radius search. Caveat, you’d have to call ssget for every mtext There’s a .DWG in the original post in the lisp forums

 
					
						 
	 
	 
                     
                     
                     
                     
                     
                     
                     
	 
					
						 
                    