Jump to content

Leaderboard

  1. Saxlle

    Saxlle

    Community Member


    • Points

      5

    • Posts

      229


  2. CyberAngel

    CyberAngel

    Trusted Member


    • Points

      4

    • Posts

      1,998


  3. Danielm103

    Danielm103

    Community Member


    • Points

      4

    • Posts

      268


  4. BIGAL

    BIGAL

    Trusted Member


    • Points

      2

    • Posts

      19,926


Popular Content

Showing content with the highest reputation since 12/22/2025 in all areas

  1. Greetings to all members of Cad Tutor, Based on the upcoming holidays and New Year, I'v made something interesting which I want it to share with you. Everything was made using a Lisp. I hope it will interesting to all of you and maybe give some inspiration to the next year to made something different and share it with rest of us . Notice (it is on cyrillic, in Serbian language): - ЗИМСКА СЛУЖБА = Winter service on roads; - СРЕЋНА НОВА ГОДИНА = HAPPY NEW YEAR; - XO-XO-XOO = HO-HO-HOO (). Happy New Year 2026 to all members, and wish you all the best and new codes . NovaGodina2026_CadTutor.mp4 Best regards, Saxlle.
    5 points
  2. Attempt number 2: This code is intended to always return a centerline whose points are all perfectly equidistant from the margins. This should happen in all cases where two LWPOLYLINEs are provided, one for each margin. The case of islands has not been considered yet. The resulting centerline is geometrically dense. This can probably be simplified in a future version. The approach taken in this code has been to obtain points from the normals and the bisectors of each margin, which are then combined at the end to build a list of points. Therefore, it is a fragmentary and massive approach. For this reason, the code is not very fast. However, there is another, more elegant approach, based on dynamically relating the geometry of both margins. It is more complex, but it would also be faster, and the error margins would be “bridgable”. If this thread has enough life in it, I may feel sufficiently motivated to finish it. That’s all for now. ;|*********************** CENTER-LINE ************************* ************************ G L A V C V S ************************* ************************** F E C I T *************************** |; (defun c:CLG (/ PI/2 lst e1 e2 l1 l2 lp lp1 lp2 p0 p> p< r1? x m a tol autoInt? ordenaPts interCpta ptEqd) (defun autoInt? (l lp / p0 p1 p2);autointersecci贸n? (if l (setq p1 (polar (car l) (setq a (angle (car l) (cadr l))) 0.001) p2 (polar (cadr l) (+ a PI) 0.001) x (if (not (vl-some '(lambda (p) (if p0 (inters p0 (setq p0 p) p1 p2) (not (setq p0 p)))) lp)) l) ) ) ) (defun ordenaPts (lst / pIni dm d ps? ps lr); puntos en orden (setq pIni (mapcar '(lambda (a b) (/ (+ a b) 2.0)) (car lp1) (car lp2))) (while lst (foreach p lst (if (and dm (/= (min (setq d (distance (if ps ps pIni) p)) dm) dm)) (setq dm d ps? p) (if (not dm) (setq dm (distance (if ps ps pIni) p) ps? p)) ) ) (setq ps ps? ps? nil dm nil lst (vl-remove ps lst) lr (cons (cadr ps) (cons (car ps) lr))) ) lr ) (defun interCpta (pM p1 p2 lp / i? i1 i2 d a b); captura de los m谩rgenes (defun i? (pA pB lp / p0 i dm is a) (foreach p lp (if p0 (if (setq i (inters p0 (setq p0 p) pA pB)) (if (and dm (/= (min (setq d (distance pM i)) dm) dm)) (setq dm d is i) (if (not dm) (setq dm (distance pm i) is i)) ) ) ) (setq p0 p) ) (if is (list (car is) (cadr is) 0.0)) ) (if (and (setq a (i? p1 p2 lp1)) (setq b (i? p1 p2 lp2))) (list a b) ) ) (defun ptEqd (A B e1 e2 / eqDist-f t0 t1 f0 f1 tm fm n i v+- v*); captura punto equidistante (defun v+- (o a b) (mapcar o a b)) (defun v* (p s) (mapcar '(lambda (x) (* x s)) p)) (defun eqDist-f (ds A B e1 e2 / pt d1 d2) (setq pt (v+- '+ A (v* (v+- '- B A) ds)); Punto sobre AB: P(ds) = A + ds (B - A) d1 (distance pt (vlax-curve-getClosestPointTo e1 pt)) d2 (distance pt (vlax-curve-getClosestPointTo e2 pt)) ) (- d1 d2) ) (setq t0 0.0 t1 1.0) (while (and (< (setq n (if n (1+ n) 0)) 100) (> (- t1 t0) 1e-6));m茅todo de bisecci贸n (setq tm (/ (+ t0 t1) 2.0) fm (eqDist-f tm A B e1 e2) ) (if (< (abs fm) 1e-9) (setq n 100 t1 tm t0 tm) (if (< (* (if f0 f0 (eqDist-f t0 A B e1 e2)) fm) 0.0) (setq t1 tm f1 fm) (setq t0 tm f0 fm) ) ) ) (if (< t1 1.0) ; par谩metro final y punto equidistante (v+- '+ A (v* (v+- '- B A) (/ (+ t0 t1) 2.0))) ) ) (if (and (setq e1 (car (entsel "\nSelect FIRST LWPolyline..."))) (= (cdr (assoc 0 (setq l1 (entget e1)))) "LWPOLYLINE") ) (if (and (setq e2 (car (entsel "\nSelect SECOND LWPolyline..."))) (= (cdr (assoc 0 (setq l2 (entget e2)))) "LWPOLYLINE") ) (progn (foreach l l1 (if (= (car l) 10) (setq lp1 (cons (cdr l) lp1)))) (foreach l l2 (if (= (car l) 10) (setq lp2 (cons (cdr l) lp2)))) (setq r1? (> (distance (car lp1) (car lp2)) (distance (car lp1) (last lp2)))) (setq tol 0.01 PI/2 (/ PI 2.) lp1 (if r1? (reverse lp1) lp1)) (foreach e (list e1 e2) (setq p0 nil m nil r? (if (equal e e1) r1?) lp (if (equal e e1) lp2 lp1)) (while (setq p (vlax-curve-getPointAtParam e (setq m (if m ((if r? 1- 1+) m) (if r? (vlax-curve-getEndParam e) 0))))) (if p0 (progn (setq lAB (autoInt? (interCpta p (polar p (setq a (+ (angle p0 p) PI/2)) 10000) (polar p (+ a PI) 10000) lp) (if (equal e e1) lp1 lp2));NORMAL AL COMIENZO DEL SEGMENTO lst (if lAB (cons (ptEqd (car lAB) (cadr lAB) e1 e2) lst) lst) ) (if (setq p> (vlax-curve-getPointAtParam e ((if r? 1- 1+) m))) (setq lAB (autoInt? (interCpta p (polar p (setq a (/ (+ (angle p p0) (angle p p>)) 2.)) 10000) (polar p (+ a PI) 10000) lp) (if (equal e e1) lp1 lp2)) ; Bisectriz lst (if lAB (cons (ptEqd (car lAB) (cadr lAB) e1 e2) lst) lst) lAB (autoInt? (interCpta p (polar p (setq a (+ (angle p p>) PI/2)) 10000) (polar p (+ a PI) 10000) lp) (if (equal e e1) lp1 lp2));NORMAL AL FINAL DEL SEGMENTO lst (if lAB (cons (ptEqd (car lAB) (cadr lAB) e1 e2) lst) lst) ) ) (setq p< p0 p0 p) ) (if (setq p> (vlax-curve-getPointAtParam e ((if r? 1- 1+) m))) (setq lAB (autoInt? (interCpta p (polar (setq p0 p) (setq a (+ (angle p0 p>) PI/2)) 10000) (polar p0 (+ a PI) 10000) lp) (if (equal e e1) lp1 lp2)) lst (if lAB (cons (ptEqd (car lAB) (cadr lAB) e1 e2) lst) lst) ) ) ) ) ) (vla-AddLightWeightPolyline (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (vlax-Make-Variant (vlax-SafeArray-Fill (vlax-Make-SafeArray 5 (cons 0 (- (length (setq lst (reverse (ordenaPts lst)))) 1))) lst)) ) ) ) ) (princ) )
    2 points
  3. Super cool to see the progress IntelliCAD has made with their C++ API. I’ve been working to port pyrx, still not released, there’s a couple small issues I need to work out import traceback from pyrx import Ap, Db, Ge # ----------------------------- # Simple spline-based vector font # ----------------------------- FONT = { "H": [[(0, 0), (0, 10)], [(5, 0), (5, 10)], [(0, 5), (5, 5)]], "A": [[(0, 0), (2.5, 10), (5, 0)], [(1.2, 5), (3.8, 5)]], "P": [[(0, 0), (0, 10)], [(0, 10), (5, 9), (5, 6), (0, 5)]], "Y": [[(0, 10), (2.5, 5)], [(5, 10), (2.5, 5)], [(2.5, 5), (2.5, 0)]], "N": [[(0, 0), (0, 10)], [(0, 10), (5, 0)], [(5, 0), (5, 10)]], "E": [[(5, 0), (0, 0), (0, 10), (5, 10)], [(0, 5), (4, 5)]], "W": [[(0, 10), (1.2, 0), (2.5, 6), (3.8, 0), (5, 10)]], "R": [[(0, 0), (0, 10)], [(0, 10), (5, 9), (5, 6), (0, 5)], [(0, 5), (5, 0)]], " ": [], } # ----------------------------- # Create a spline from points # ----------------------------- def add_spline(ms, pts, base, scale): arr = [] for p in pts: arr.append(Ge.Point3d(base.x + p[0] * scale, base.y + p[1] * scale, 0.0)) spline = Db.Spline(arr, 3, 0.0) ms.appendAcDbEntity(spline) # ----------------------------- # Write text as splines # ----------------------------- def write_happy_new_year(start=Ge.Point3d(0, 0, 0), scale=5.0, spacing=8.0): db = Db.curDb() ms = Db.BlockTableRecord(db.modelSpaceId(), Db.OpenMode.kForWrite) cursor = Ge.Point3d(start.x, start.y, 0) text = "HAPPY NEW YEAR" for ch in text: strokes = FONT.get(ch.upper(), []) for stroke in strokes: add_spline(ms, stroke, cursor, scale) cursor.x += spacing * scale # ----------------------------- # Entry point # ----------------------------- def PyRxCmd_HAPPYNEWYEAR(): try: write_happy_new_year(start=Ge.Point3d(0, 0, 0), scale=2.5, spacing=7.0) except Exception as err: traceback.print_exception(err)
    1 point
  4. Some really cool stuff here
    1 point
  5. Here’s a test extracting data from multiple drawings import traceback import pandas as pd import os from pyrx import Ap, Db, Ed, Ge def proccessDrawing(db: Db.Database, data: dict): blk_dict = db.getBlocks() fname = os.path.basename(db.getFilename()) data[fname] = [] for name, id in blk_dict.items(): if name != "RMNUM": continue btr = Db.BlockTableRecord(id) for refid in btr.getBlockReferenceIds(): blkref = Db.BlockReference(refid) for attid in blkref.attributeIds(): attref = Db.AttributeReference(attid) data[fname].append(attref.textString()) def openSideDatabase(dwg_path: str, data: dict): sdb = Db.Database(False, True) sdb.readDwgFile(dwg_path) sdb.closeInput(True) proccessDrawing(sdb, data) @Ap.Command() def doit(): try: data = {} dwgs = Ap.Application.listFilesInPath("E:\\FloorPlans", ".dwg") for dwg in dwgs: openSideDatabase(dwg, data) df = pd.DataFrame(data) print(df) except Exception as err: traceback.print_exception(err) output : Success module _DOIT is loaded: Command: doit 1st floor.dwg 2nd floor.dwg 3rd floor.dwg 0 1049 2049 3049 1 1045 2045 3045 2 1032 2032 3032 3 1048 2048 3048 4 1046 2046 3046 .. ... ... ... 94 1122 2122 3122 95 1106 2106 3106 96 1104 2104 3104 97 1093 2093 3093 98 1042 2042 3042 [99 rows x 3 columns]
    1 point
  6. Need more information. What exactly are you doing, step by step? Do you have MAP 3D?
    1 point
  7. What you'll probably need to do is set the proper coordinate system in your viewport. To make things simpler, you can create the proper view with UCS, give it a name, and save it. That way you can use it as many times as you need to. To prepare your plan, go to paper space, open the viewport, and "restore" the view. Once you have your linework at the right scale, angle, and location, lock the viewport. If your model is not supposed to look like a wireframe, check the properties for the Visual Style while in model space. If this doesn't help, please give us more information.
    1 point
  8. To test my memory, I opened the default drawing, created a new scale 1:1, and drew a couple of objects and a dimension. I made the dimension annotative and gave it the 1:1 scale. I copied those objects to the clipboard. Then I opened a second new drawing, which had our template settings, including a 1:1 scale. I pasted the objects from the clipboard into the second drawing. You'll never guess what happened. The pasted dimension had a scale of 1:1_1. In other words, that's the type of name AutoCAD gives a duplicate scale when it doesn't want you to rename an arbitrarily large group of settings. Does that shed any light on the issue?
    1 point
  9. How is "1:1_1" different from "1:1"? Is it possible there's a duplicate scale?
    1 point
  10. I think with those big side offshoots you need to break the river into multiple plines so you would have two or more centrelines lines in that situation. As suggested by @SLW210 The problem will be how to work out the break offset shape.. Ps image dummied up.
    1 point
  11. I think the real-world situation may be more complex than what we’ve seen here so far. I took a look at the links that @SLW210 attached and decided to test the Lisp codes proposed up to this point. I looked through my drawings for something that could serve as an example for this problem, but it was like looking for a needle in a haystack. So, in the end, I decided to look for something in the real world that clearly corresponds to this issue — something like this: So I drew those margins and tested all the codes that have appeared in this thread so far. The result was… this! In the drawing, you can see the ones that managed to reach the end. However, the codes by BIGAL, GP_, GLAVCVS, and MarkoRibar couldn't even do that. Here’s the drawing AxisExple4.dwg
    1 point
  12. Nice test @PGia, thanks! For some reason I didnt consider closed polylines in the _checkOffset function, so I added an extra check there. Should work as expected now: Not sure about the short corner. The lines are so narrow the centerline is pushed back out of the point. Seems to be logical to me but it does feel intuitive. Narrow indents don't get much love from the centerline. So "inlets" don't have enough influence on the shape of the line. What would the expected result be? Below makes sense since there is not enough space to go into the indent. Or are you maybe something like this where the line splits and goes into the hole:
    1 point
  13. if you just want to go up and down use Ctrl+Pgdn, Ctrl+Pgup. This will let you jump to any layout. Goto-layout.lsp
    1 point
  14. gsksun4 - It allows you to maximize the viewport. This gives you a model space view while working in a viewport. The advantage of working in this mode is the ability to work in model space with all the layers frozen in the viewport. You can double click outside the "red rope" to minimize the view.
    1 point
  15. Just curious, why don't you scale and lock your viewport while you are inside the viewport? Select the scale from the viewport scale list on the status bar and then click on the padlock.
    1 point
×
×
  • Create New...