p7q Posted August 22 Author Posted August 22 22 hours ago, Steven P said: That's strange, in my testing it works as I expected. Are you able to post a sample drawing with an arc that rotates? Going to look at the other object types sometime today for you. There is a list at the top of 'Flatten Lines' that work at the moment for info. Thanks for interest. you can try this dwg also. I 'm waiting yours code. arc.dwg Quote
p7q Posted August 22 Author Posted August 22 17 hours ago, mhupp said: Then something wasn't created or modified. aka trying to exploding a invalid or corrupted region, or one that is on a locked layer. maybe run audit and purge before and then check if entity is on a locked layers. -Edit Writing lisp isn't the hard part. figuring out all the different things that could go wrong and how to handle that is the hard part. had a user that would always select things with the crossing selection option(bottom right to top left) and complain about how my lisp was picking up things "outside" what they where selecting. I'm sure I did because I tried exploding an object. But it didn't fill. There must be an error somewhere, but I couldn't find it, so I tried another method. Also, I'm a new programmer and I started writing lips without knowing anything about ACAD, so it was extra difficult. I'm glad this forum exists :))) 1 Quote
p7q Posted August 22 Author Posted August 22 18 hours ago, Isaac26a said: I found it making a google research is at: https://sites.google.com/site/cadkits/home/chz20 And I don't know if this is of some help ı tried but dindt work for arc. But thanks for interest Quote
Steven P Posted August 22 Posted August 22 arcs in this case will need to be converted to ellipses to display properly.. something to think about 1 Quote
Isaac26a Posted August 22 Posted August 22 (edited) 7 hours ago, Steven P said: arcs in this case will need to be converted to ellipses to display properly.. something to think about As Steven P said, your arcs in order to keep the same display or look should be converted to ellipses or splines, because they are in 3d and to be displayed in 2d should be converted because they're not plain sections of circles as an arc in 2d is meant to be, that's why most of the codes don't apply to what you want Edited August 22 by Isaac26a Typos 1 Quote
Danielm103 Posted August 23 Posted August 23 (edited) see if this drawing is correct. I used project from pyrx import Ap, Ax, Db, Ed, Ge from timeit import default_timer as timer # register command @Ap.Command() def doit(): try: db = Db.curDb() # selection set ps, ss = Ed.Editor.select() if ps != Ed.PromptStatus.eOk: raise RuntimeError("Selection Error! {}: ".format(ps)) start = timer() failedEnts = set() newents = [] # createa plane to project on to plane = Ge.Plane(Ge.Point3d.kOrigin,Ge.Vector3d.kZAxis) for id in ss.objectIds(Db.Curve.desc()): dbc = Db.Curve(id) try: gec = dbc.getAcGeCurve() # project geproj = gec.project(plane,Ge.Vector3d.kZAxis) if not geproj.isKindOf(Ge.kCurve3d): continue geprojCurve = Ge.Curve3d.cast(geproj) #convert to AcDbCurve dbproj = Db.Core.convertGelibCurveToAcDbCurve(geprojCurve) dbproj.setDatabaseDefaults() dbproj.setLayer(dbc.layer()) newents.append(dbproj) #erase the old dbc.upgradeOpen() dbc.erase() # do linetypes except: failedEnts.add(dbc.isA().name()) #add the new flattened entities db.addToModelspace(newents) end = timer() print(end - start) except Exception as err: print(err) Edited August 29 by Danielm103 updated code Quote
Steven P Posted August 26 Posted August 26 Coming back to this one, I was thinking first off a simple task to write something faster - things like the arcs to ellipses slowing things down a bit. Maybe a different approach, are you able to share the LISP you have now, the one that works, and we can look to see if we can make it work faster? Quote
p7q Posted August 28 Author Posted August 28 On 8/26/2025 at 4:33 PM, Steven P said: Coming back to this one, I was thinking first off a simple task to write something faster - things like the arcs to ellipses slowing things down a bit. Maybe a different approach, are you able to share the LISP you have now, the one that works, and we can look to see if we can make it work faster? Unfortunately, I can’t share the LISP code itself, but I can explain the underlying logic.I use a helper function that processes each entity type. When it encounters a block, it gathers the block’s contents into a list; once the top-level selection is done, it feeds that list back into the same function to process all nested entities.” Quote
Danielm103 Posted August 28 Posted August 28 Did you have a look at my drawing? Python converted those arcs to ellipses in milliseconds. If you can run python, then it would be pretty easy to make it callable from lisp Quote
p7q Posted August 28 Author Posted August 28 35 minutes ago, Danielm103 said: Did you have a look at my drawing? Python converted those arcs to ellipses in milliseconds. If you can run python, then it would be pretty easy to make it callable from lisp sorry ı dont know how to use this code in acad. I'm trying Quote
Isaac26a Posted August 28 Posted August 28 48 minutes ago, Danielm103 said: Did you have a look at my drawing? Python converted those arcs to ellipses in milliseconds. If you can run python, then it would be pretty easy to make it callable from lisp That sounds to me that you are trying to pull us to the dark side, sounds pretty tempting, would you walk us through? 1 Quote
Danielm103 Posted August 28 Posted August 28 (edited) 37 minutes ago, Isaac26a said: That sounds to me that you are trying to pull us to the dark side, sounds pretty tempting, would you walk us through? LOL! Only for items that look difficult, or painful in lisp, where there’s a possible built in function. This drawing took 0.03673760 seconds to process. if the drawing is indeed correct, have a look here for how to run python https://github.com/CEXT-Dan/PyRx arc2.dwg Edited August 28 by Danielm103 1 Quote
BlackBox Posted 1 hour ago Posted 1 hour ago (edited) This thread was mentioned in a similar discussion, so sharing my reply here in kind. If you can compile .NET, use @Danielm103's code - if you instead use Visual LISP, this may help: 3 minutes ago, BlackBox said: This does: (defun c:FOO (/ *error* _move _set elev acDoc ss objName pt i) (defun *error* (msg) (if ss (vla-delete ss)) (if acDoc (vla-endundomark acDoc)) (cond ((not msg)) ; Normal exit ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit) ((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it ) (princ) ) (defun _move (prop /) (vla-move x (vlax-3d-point '(0 0 0)) (vlax-3d-point (mapcar '- (list (car (setq pt (vlax-get x prop))) (cadr pt) elev) pt ) ) ) ) (defun _set (prop /) (vlax-put x prop (list (car (setq pt (vlax-get x prop))) (cadr pt) elev ) ) ) (if (and (ssget "_:L" '( (0 . "ARC,ATTDEF,CIRCLE,DIMENSION,ELLIPSE,HATCH,INSERT,*LEADER,LINE,*POLYLINE,MTEXT,POINT,REGION,SOLID,SPLINE,TEXT" ) ) ) ;; someone asked if they could pick a point: ;;(setq elev (getpoint "\nSpecify point for elevation: ")) ;;(setq elev (last elev)) (setq elev (getreal "\nEnter an elevation: ")) ) (progn (vla-startundomark (setq acDoc (vla-get-activedocument (vlax-get-acad-object))) ) (vlax-for x (setq ss (vla-get-activeselectionset acDoc)) (setq pt nil) (cond ((vl-position (setq objName (vla-get-objectname x)) '("AcDbArc" "AcDbCircle" "AcDbEllipse") ) (_set "center") ) ((vl-position objName '("AcDbAttributeDefinition" "AcDbMText" "AcDbText")) (_set "insertionpoint") ) ((wcmatch objName "AcDb*Dimension") (_move "textposition") ) ((= "AcDbBlockReference" objName) ;; <-- test for and ignore xrefs here, if needed (_set "insertionpoint") ) ((= "AcDbLine" objName) (_set "startpoint") (_set "endpoint") ) ((= "AcDbPoint" objName) (_set "coordinates") ) ((vl-position objName '("AcDbHatch" "AcDbPolyline" "AcDb2dPolyline")) (vla-put-elevation x elev) ) ((vl-position objName '("AcDb3dPolyline" "AcDbLeader" "AcDbSolid")) (setq pt (vlax-get x 'coordinates)) (setq i 0) (setq pt (mapcar (function (lambda (n) (setq i (1+ i)) (if (= 0 (rem i 3)) elev n ) ) ) pt ) ) (vlax-put x 'coordinates pt) ) ((= "AcDbMLeader" objName) (setq pt (vlax-invoke x 'GetLeaderLineVertices 0)) (vla-move x (vlax-3d-point (setq pt (list (car pt) (cadr pt) (caddr pt))) ) (vlax-3d-point (list (car pt) (cadr pt) elev)) ) ) ((= "AcDbRegion" objName) (setq pt (vlax-get (car (setq i (vlax-invoke x 'explode))) 'startpoint ) ) (vla-move x (vlax-3d-point (setq pt (list (car pt) (cadr pt) (nth 2 pt))) ) (vlax-3d-point (list (car pt) (cadr pt) elev)) ) (foreach line i (vla-delete line)) ) ((= "AcDbSpline" objName) (if (= :vlax-true (vla-get-isplanar x)) (progn (setq pt (vlax-get x 'controlpoints)) (vla-move x (vlax-3d-point (setq pt (list (car pt) (cadr pt) (nth 2 pt))) ) (vlax-3d-point (list (car pt) (cadr pt) elev)) ) ) (progn (setq x (entget (vlax-vla-object->ename x))) (setq x (mapcar (function (lambda (p) (cond ((and (member (car p) '(10 11 12 13)) (listp (cdr p)) (= 3 (length (cdr p))) ) (list (car p) (cadr p) (caddr p) elev ) ) (t p) ) ) ) x ) ) (entmod x) ) ) ) (T nil) ) ) ) ) (*error* nil) ) Edited 1 hour ago by BlackBox 1 Quote
Danielm103 Posted 53 minutes ago Posted 53 minutes ago FYI, it’s not .NET, it’s Python, so no compiling required https://github.com/CEXT-Dan/PyRx Though .NET certainly would work, the function is AcGeCurve3d::project Maybe similar to PROJECTGEOMETRY Quote
BlackBox Posted 32 minutes ago Posted 32 minutes ago 13 minutes ago, Danielm103 said: FYI, it’s not .NET, it’s Python, so no compiling required https://github.com/CEXT-Dan/PyRx Though .NET certainly would work, the function is AcGeCurve3d::project Maybe similar to PROJECTGEOMETRY It was more of a qualifier... While I'm sure they exist, I've never personally met anyone who used Python and couldn't compile .NET Haha 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.