Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. Thanks Steven added the C :, I normally load lisps like this so last line could be (C:rec2lays) so it runs on load. I don't understand why @iztok14 why your bothering making a layout that reflects the rectangs in "Model", you can say plot all rectangs in Model without having to select.
  3. Danielm103

    Anatomy of an AcDbObject in Python.

    More in AcDbObject open state AcDbObjects baslically live in three different states, Closed, ForRead, ForWrite In Python (most) every DBObject has a minimum of four constructor overloads # is a new line that does not belong to the database yet dbo = Db.Line() # or dbo = Db.Line(Ge.Point3d(0,0,0),Ge.Point3d(100,0,0)) # is an existing line opened for read dbo = Db.Line(id) # or explicit dbo = Db.Line(id, Db.OpenMode.kForRead) # is an existing line opened for write dbo = Db.Line(id, Db.OpenMode.kForWrite) You can also change the state of the object # upgradeOpen dbo to write dbo = Db.Line(id, Db.OpenMode.kForRead) dbo.upgradeOpen() # upgradeOpen dbo to write dbo = Db.Line(id, Db.OpenMode.kForWrite) dbo.downgradeOpen()
  4. Danielm103

    Selection sets in Python.

    Select objects inside a boundary, where the boundary can be any curve. In this example, I use AcGeCurve3d::getSamplePoints to build a window, the points are equally spaced by parameter value. You can also use the same technique to build a custom selection fence # see https://github.com/CEXT-Dan/PyRx import traceback from pyrx import Db, Ap, Ed @Ap.Command() def doit(): try: ps, id, _ = Ed.Editor.entSel("\nSelect boundary: ") if ps != Ed.PromptStatus.eOk: raise RuntimeError("Selection Error! {}: ".format(ps)) dbcrv = Db.Curve(id) gecrv = dbcrv.getAcGeCurve() smpls = gecrv.getSamplePoints(100) ps , ss = Ed.Editor.selectWindowPolygon(smpls[0]) if ps != Ed.PromptStatus.eOk: raise RuntimeError("Selection Error! {}: ".format(ps)) for _id in ss.objectIds(): ent = Db.Entity(_id,Db.OpenMode.kForWrite) ent.highlight() except Exception as err: traceback.print_exception(err)
  5. Today
  6. Well, it's been five days since you asked for assistance. Have you made any progress at all? I would be willing to show you what I have accomplished but not before I see what you have done.
  7. SLW210

    Hybrid parallel

    There lies the main issue with this, the last sentence is actually incorrect. Unless you have 2 exactly parallel lines/polylines the result is always going to be an approximation, the less different the better, but still just an approximation, even if you compare every conceivable point, if they are different lengths it's odd man out. If it's a very complicated pair of lines, you would need a lot of points to calculate, hence very slow. Jeffery P Sanders Rolling_Ball.lsp appears to get pretty close. This issue comes up all the time, just go to anything related to Civil 3D, GIS, etc. Example https://discourse.mcneel.com/t/finding-the-average-curve-between-two-curves/149668 If you want some unattainable perfection, I suggest you invest in modern software.
  8. try: (rec2lays) Include the ( ) - looks like BigAl has done it all 'wrong' - or it is a part of a more complex thing (a lot more likely) and has forgotten to add the c in the function name, Could also alter first line to be: (defun c:rec2lays ( / ss en.....
  9. @Hsanon the only way I can reproduse what you show is if "exist" layer dosen't exist. I don't see that layer in the video you shared. MAKE THIS LAYER BEFORE RUNNING THE LISP AS SHOWN IN MY VIDEO.
  10. And its not happening on my machine......am i doing anything wrong ???? is it an autocad issue ??? attaching a screen recording... sorry to be such a bother !!!!! changing layers.mp4
  11. Sorry fot late answer, i was away for weekend. I tried "rec2lays" lisp but doesnt work for me ? noting hapend when i type command "rec2lays". Yes i d like to have vieports in only one layout side by side ? The scale is 1:1 model layout. thy, Iztok
  12. @Hsanon I tried both lisps and they work. @BIGAL lisp works - after you run the command you need to select the boundery polygon. with my lisp - before runnig it you need to make sure both "exist" and "site" layers exist. in your case you need to create "exist" layer. See attached Video using my lisp. Recording 2025-11-10 110909.mp4
  13. Hi, many thanks for your help Aridzv and BigAl, But, all entities are being converted to layer "site". The ones inside the pline are not being moved to layer "exist" I'm attaching the drawing on which I am testing. surveytest.dwg
  14. BIGAL

    Hybrid parallel

    "Plines in same direction", Yes Lee-Mac has a method also. Note the use of Pedit as Bricscad does not have a "Reverse" command, as at V25. ; Checking if pline is CW or CCW and set to CCW ; Orignal idea by Kent Cooper, 1 August 2018 Offsetinorout.lsp ; By Alan H July 2020 (defun AH:chkcwccw (ent / objnew area1 area2 obj minpoint maxpoint) (setq obj (vlax-ename->vla-object ent)) (vla-GetBoundingBox obj 'minpoint 'maxpoint) (setq pointmin (vlax-safearray->list minpoint)) (setq pointmax (vlax-safearray->list maxpoint)) (setq dist (/ (distance pointmin pointmax) 20.0)) (vla-offset obj dist) (setq objnew (vlax-ename->vla-object (entlast))) (setq area1 (vlax-get objnew 'Area)) (vla-delete objnew) (vla-offset obj (- dist)) (setq objnew (vlax-ename->vla-object (entlast))) (setq area2 (vlax-get objnew 'Area)) (vla-delete objnew) (if (> area1 area2) (command "Pedit" ent "R" "") ) (princ) ) (defun c:CWCCW ( / *error* x ent oldsnap doc ss) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark doc) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (prompt (strcat "\nSelect Plines to check")) (if (setq ss (ssget '((0 . "*POLYLINE")))) (progn (repeat (setq x (sslength ss)) (setq ent (ssname ss (setq x (- x 1)))) (AH:chkcwccw ent) ) ) ) (vla-endundomark doc) (alert (strcat (rtos y 2 0) " Plines reversed")) (setvar 'osmode oldsnap) (princ) ) (vl-load-com) (prompt "\nType CWCCW to set plines to CCW") (c:CWCCW)
  15. Yesterday
  16. Craig Rathke

    Curb offset

    @BIGAL You lisp works very well, but I spend alot of time having to delete offsets if I'm not sure where the true start of line is....especially with close polylines. It will always seems to offset the wrong direction and I end up having to reverse the original closed polyline. (FYI I am trying to use a slightly altered version of your code, using a -0.5' offset for the back of curb since I want to offset to both sides based on the initially drawn face of curb for parking lots.) Is there any way the code can be altered in this way: Instead of selecting the beginning point of the object, you just select the object normally, then it prompts you to select the side of the back of curb (in your code, that would be the off1) and then I get an offset to both sides of the selected line..a BOC (off1) and an EOP (off2). This adds an extra click but makes sure I offset the correct direction. I'm not sure how to begin to do this. Any help would be appreciated. Thanks!!! -Craig
  17. PGia

    Hybrid parallel

    I’m sorry. I didn’t think this was important — but maybe I was wrong. I usually copy drawings from my PC to edit them on my smartphone. The app I use on my smartphone is DWG FastView. I don’t remember where I sent it from, but if that message appeared when opening it, it must be because I saved the drawing on my smartphone for some reason and sent it from there.
  18. Steven P

    Hybrid parallel

    I think Lee Mac had something to work out polyline direction, so should be able to check and reverse a polyline if necessary. Reverse back again after
  19. SLW210

    Hybrid parallel

    From what I have gathered, no easy task to do this, many GIS programs seem to struggle with pinpoint accuracy as well. The method for QGIS, is involved, so I didn't get time to run through it with the plugin, but I did dig into reddit and some GIS sites. Basically they do similar method, they just add a lot of points down the "polyline/line" and run the appropriate "centerline tool". Where someone posted results, I saw some in some of them the same "off center through some areas" as in the methods posted here. This was apparently plenty good enough for most GIS users, though I only did a relatively quick dig. In a similar method for AutoCAD, maybe adding more points to the polylines would help. I might have time Monday at home to check QGIS. Though I did import the OPs drawings into a session, the first one comes in very strange, the second seemed to be correct. The OP still hasn't answered why the second .dwg posted comes up as not an AutoCAD drawing. For AutoCAD, it helps if BOTH polylines go the same direction.
  20. My $0.05 does not check for off or frozen layers. (defun c:wow ( / ent co-ord ss) (if (tblsearch "layer" "Site") (princ) (command "-layer" "Make" "Site" "c" 1 "" "") ) (if (tblsearch "layer" "Exist") (princ) (command "-layer" "Make" "Exist" "c" 2 "" "") ) (command "chprop" "all" "" "la" "Site" "") (setq ent (car (entsel "\nPick the pline "))) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ent)))) (setq ss (ssget "WP" Co-ord)) (command "chprop" ss "" "LA" "Exist" "") (princ) ) (c:wow)
  21. Last week
  22. mhupp

    Hybrid parallel

    I Created a closed polyline and offsetting in. the smaller the offset the more "detail" (points) you get but you need them to get the right vertex or you just cutting corners. I don't really know how to pick up those points and don't really want to offset 1cm and have a million points either. CPL offset.dxf
  23. see new code. make sure the layers names are correct. (defun c:chglyobjpl (/ acdoc p_list p_coord sset ent obj newLayerName newLayerName1 i) (vl-load-com) (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))) (princ "\nSelect All Objects To Proccess") (setq ssall (ssget)) (setq p_list (entget (car (entsel "\nSelect the Polyline Boundery For ''exist'' Layer: ")))) (setq i 0) ;;;;;;;;;;;;;;;;;;;;;;;;;;;Change Objects To site Layer;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (if ssall (progn (sssetfirst nil nil) (setq newLayerName1 "site");;(getstring T "\nEnter new layer name: ")) (repeat (setq i (sslength ssall)) (setq i (1- i)) (setq ent (ssname ssall i)) (setq obj (vlax-ename->vla-object ent)) (vla-put-Layer obj newLayerName1) );;repeat (vla-Regen acdoc acAllViewports) (sssetfirst nil nil) );;progn (princ "\nNo objects found in the drawing.") );;if ;;;;;;;;;;;;;;;;;;;;;;;;;;;Change Objects To site Layer;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq ent nil) (setq obj nil) (setq i 0) ;;;;;;;;;;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-set-using-existing-polygon/td-p/11307274 ;;;;;;;;;;;calderg1000 msg-7 (if (setq p_coord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) p_list) );;end setq p_coord );;end if condition (sssetfirst nil (setq sset (ssget "_wp" p_coord))) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;Select Objects In polygon;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;Change Objects Layer;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (if sset (progn (sssetfirst nil nil) (setq newLayerName "exist");;(getstring T "\nEnter new layer name: ")) (repeat (setq i (sslength sset)) (setq i (1- i)) (setq ent (ssname sset i)) (setq obj (vlax-ename->vla-object ent)) (vla-put-Layer obj newLayerName) );;repeat (vla-Regen acdoc acAllViewports) (sssetfirst nil nil) );;progn (princ "\nNo objects found in the drawing.") );;if ;;;;;;;;;;;;;;;;;;;;;;;;;;;;Change Objects To exist Layer;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (sssetfirst nil nil) (princ) );;end defun test1.mp4
  24. Thanks ... but..... on running the program, its saying that "no objects found in the drawing" and the program closes
  25. I used the lisp called cookie cutter .. it worked like magic thank you SLW210
  26. Try this: (defun c:chglyobjpl (/ acdoc p_list p_coord sset ent obj newLayerName i) (vl-load-com) (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))) ;;;;;;;;;;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-set-using-existing-polygon/td-p/11307274 ;;;;;;;;;;;calderg1000 msg-7 (setq p_list (entget (car (entsel "\nSelect the LwPolyline: ")))) (if (setq p_coord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) p_list) );;end setq p_coord );;end if condition (sssetfirst nil (setq sset (ssget "_wp" p_coord))) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;Select Objects In polygon;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;Change Objects Layer;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (if sset (progn (setq newLayerName "exist") ;;(getstring T "\nEnter new layer name: ")) (repeat (setq i (sslength sset)) (setq i (1- i)) (setq ent (ssname sset i)) (setq obj (vlax-ename->vla-object ent)) (vla-put-Layer obj newLayerName) );;repeat (vla-Regen acdoc acAllViewports) (sssetfirst nil nil) );;progn (princ "\nNo objects found in the drawing.") );;if ;;;;;;;;;;;;;;;;;;;;;;;;;;;;Change Objects Layer;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (princ) );;end defun
  27. If you want to have a go, look at Selection Sets to select everything within the polyline (see Lee Mac Selection sets page - it is rather good - ssget), window polygon or crossing polygon Do 2 selection sets - one for everything "_X" and one for Crossing Polygon, I think Lee Mac has a routine there to remove one selection set from another. This gives you 2 sets of entities to work with Loads of LISPs out there to change layers. Have a go, it is easier than you might think
  28. Hi, Is there a Lisp routine which can move all objects within a selected polyline to a layer called "exist" and all objects outside that same polyline to a layer called "site" ?? ignoring all frozen or OFF layers ?? Regards.
  29. This is very much proof of concept, and needs some extra work but you can try it. I just did 162 layouts by selection did not try all 300+. You must use this new dwg as it has Layout1 set up correctly. I removed layout2 not needed. Obvious bug is if rectangs are not made in correct label sequence but can fix that if it happens. It uses creation order at moment. You should use 1 size for all the rectangs. ; https://www.cadtutor.net/forum/topic/98809-multiple-polyline-viewport-from-model-to-layout/ ; rectangs to layouts by AlanH ; Nov 2025 (defun rec2lays ( / ss ent txt ins pt2 pts ent2 co-ord mp ) (setvar 'ctab "Model") (setq ss (ssget (list (cons 0 "*TEXT") (cons 8 "SHEMA_NAME")(cons 410 "Model")))) (repeat (setq x (sslength ss)) (setq ent (entget (ssname ss (setq x (1- x))))) (setq txt (cdr (assoc 1 ent))) (setq ins (cdr (assoc 10 ent))) (setq pt2 (polar ins 5.4977 2.5)) (setq pts (list ins pt2)) (setq ent2 (ssname (ssget "F" pts (list (cons 0 "LWPOLYLINE")(cons 8 "SHEMA_RECT"))) 0)) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ent2)))) (setq mp (mapcar '* (mapcar '+ (car co-ord) (caddr co-ord)) '(0.5 0.5))) (command "layout" "C" "Layout1" txt) (setvar 'ctab txt) (command "Mspace") (command "zoom" "c" mp 10) (command "zoom" "15XP") ; a custom scale of 15 seems to suit (command "Pspace") (setvar 'ctab "Model") ) (princ) ) sheme_JAS.dwg
  1. Load more activity
×
×
  • Create New...