Leaderboard
Popular Content
Showing content with the highest reputation on 01/22/2025 in all areas
-
@GLAVCVS gracias, now the number of circles is counted only inside the contour.1 point
-
If you want someone to take a look at your file you should upload it here in the forum. Some people have restrictions at their workplace so they can't visit certain sites or download files, and speaking for myself, I don't like clicking on links to external sites. If you're not sure how to upload a file, take a look at this post:1 point
-
(defun c:Circles_Chess_outl (/ oddp ent step radius vlist minx miny maxx maxy x y row pt osmant circulos creaMTEXT ) ;;----------------------------------------------- ;; THE FUNCTION OF CHECKING WHETHER THE NUMBER IS ODD ;;----------------------------------------------- (defun oddp (n) (= (logand (fix n) 1) 1) ) ;;----------------------------------------------- ;; Local auxiliary functions ;;----------------------------------------------- ;; Extracting a list of vertices (points) of a linear 2D polyline: (defun getPolyVertices (e / ed lst pts) (setq ed (entget e) ;; selecting all groups of the DXF = 10 code (coordinates of the vertices) lst (vl-remove-if-not '(lambda (x) (= (car x) 10)) ed ) ;; turning them into a regular list of points (x y) pts (mapcar 'cdr lst) ) (if (vlax-get-property (vlax-ename->vla-object e) "Closed") (append pts (list (car pts))) pts ) ) ;; Checking whether the pt point is located inside the linear polygon v list: ;;; (defun pointInPolygon (pt vlist / cnt i v1 v2) ;;; (setq cnt 0 ;;; i 0 ;;; ) ;;; ;; "Let's "block" the list so that we can bypass the pair (list[i], list[i+1]): ;;; (setq vlist (append vlist (list (car vlist)))) ;;; (repeat (1- (length vlist)) ;;; (setq v1 (nth i vlist) ;;; v2 (nth (1+ i) vlist) ;;; i (1+ i) ;;; ) ;;; (if (edgeIntersectsRay pt v1 v2) ;;; (setq cnt (1+ cnt)) ;;; ) ;;; ) ;;; ;; If the number of intersections with the ray is odd, the point inside ;;; (if (= (logand cnt 1) 1) ;;; T ;;; nil ;;; ) ;;; ) (defun comprobar_centralidad (pto lst_ptos_rto / pt_inters+ pt_inters- n pt1 pt2 inters_negat inters_posit ) (setq n 0) (repeat (- (length lst_ptos_rto) 1) (setq pt_inters+ (inters pto (list (+ (car pto) 100000) (cadr pto)) (setq pt1 (nth n lst_ptos_rto)) (setq pt2 (nth (+ n 1) lst_ptos_rto)) ) ) (if (and pt_inters+ (not (member (cons 10 pt_inters+) lst_ptos_rto)) ) (if inters_posit (setq inters_posit (+ inters_posit 1)) (setq inters_posit 1) ) ) (setq pt_inters- (inters pto (list (- (car pto) 100000) (cadr pto)) pt1 pt2 ) ) (if (and pt_inters- (not (member (cons 10 pt_inters-) lst_ptos_rto)) ) (if inters_negat (setq inters_negat (+ inters_negat 1)) (setq inters_negat 1) ) ) (setq n (+ n 1)) ) ;;; (print (list (strcat "Punto: " (rtos (car pto) 2 2) "," (rtos (cadr pto) 2 2)) inters_negat inters_posit)) (if (and (= (rem (if (not inters_negat) 0 inters_negat ) 2 ) 0 ) (= (rem (if (not inters_posit) 0 inters_posit ) 2 ) 0 ) ) nil T ) ) (defun creaMTEXT (texto altura / vlaEnt) (setq vlaEnt (vla-AddMText (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (vlax-3d-point ptx) 50 texto)) (vlax-put-property vlaEnt "Height" altura) ) (defun creaCIRCULO (pto radio / vlaEnt) (setq vlaEnt (vla-AddCircle (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (vlax-3d-point pto) radio)) ) ;; Checking the intersection of the horizontal ray to the right of pt with the segment (v1,v2): (defun edgeIntersectsRay (pt v1 v2 / px py x1 y1 x2 y2) (setq px (car pt) py (cadr pt) x1 (car v1) y1 (cadr v1) x2 (car v2) y2 (cadr v2) ) ;; Let's ensure that (x1,y1) is "lower" than (x2,y2): (if (> y1 y2) (progn (setq x1 (car v2) y1 (cadr v2) x2 (car v1) y2 (cadr v1) ) ) ) ;; Intersection condition: (and ;; 1) py is strictly above the lower vertex and not higher than the upper one (> py y1) (<= py y2) ;; 2) px < abscissas of the intersection point of the ray with the segment (defun edgeIntersectsRay (pt v1 v2 / px py x1 y1 x2 y2 intersectX) (setq px (car pt) py (cadr pt) x1 (car v1) y1 (cadr v1) x2 (car v2) y2 (cadr v2) ) ) ;; Let's ensure that (x1,y1) is "lower" than (x2,y2) (if (> y1 y2) (setq x1 (car v2) y1 (cadr v2) x2 (car v1) y2 (cadr v1) ) ) ) ;; Counting the intersection coordinate (setq intersectX (if (/= y2 y1) (+ x1 (* (- py y1) (/ (- x2 x1) (- y2 y1)))) x1 ;; if the segment is horizontal, it is usually skipped. ) ) ;; We are returning (and ...), or nil (and (> py y1) ;; a point above the lower vertex (<= py y2) ;; and no higher than the top (> intersectX px) ) ) ;;----------------------------------------------- ;; the main part ;;----------------------------------------------- (setq ent (car (entsel "\nChoose a closed linear polyline: "))) (if (null ent) (progn (prompt "\nThe polyline is not selected. Completion.") (princ) ) (progn ;; 1) Step Request (setq step (getreal "\nEnter the step between the centers (??): ") ) (if (or (null step) (<= step 0.0)) (setq step 50.0) ;; the "backup" option ) ;; 2) Fixed radius (setq radius 2.0) ;; 3) List of vertices (minimum 3, otherwise not a polygon) (setq vlist (getPolyVertices ent)) (if (< (length vlist) 3) (progn (prompt "\nThe polyline has <3 vertices, and the contour is incorrect." ) (princ) ) (progn ;; 4) Defining bounding box (setq minx (apply 'min (mapcar 'car vlist)) maxx (apply 'max (mapcar 'car vlist)) miny (apply 'min (mapcar 'cadr vlist)) maxy (apply 'max (mapcar 'cadr vlist)) ) (prompt (strcat "\nboundary (bounding box) polyline:\n" " X: " (rtos minx 2 2) " ... " (rtos maxx 2 2) "\n Y: " (rtos miny 2 2) " ... " (rtos maxy 2 2) ) ) ;; 5) Building a grid "in a staggered manner" (setq row 0 y miny circulos 0 ) (setq osmant (getvar "osmode")) (setvar "osmode" 0) (while (<= y maxy) ;; For an odd row row, we shift X by step/2 (if (oddp row) (setq x (+ minx (/ step 2.0))) (setq x minx) ) (while (<= x maxx) (setq pt (list x y)) ;; If the center is inside the polyline, draw a circle. (if (comprobar_centralidad pt vlist) ;(pointInPolygon pt vlist) (progn ;;; (command "_.CIRCLE" pt radius) (creaCIRCULO pt radius) (setq circulos (+ circulos 1)) ) ) (setq x (+ x step)) ) (setq y (+ y step)) (setq row (1+ row)) ) (vla-regen (vla-get-activedocument (vlax-get-acad-object)) 0) (if (setq conj (ssget "_wp" vlist '((0 . "CIRCLE")))) (progn (princ (strcat "\nTotal number of cicles drawn: " (itoa circulos))) (setq circulos (sslength conj)) ) ) (if (setq ptx (getpoint "\nPick insertion point for circle number text (right click or ENTER for skip)...")) (vla-AddText (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (itoa circulos) (VLAX-3D-POINT ptx) radius) ) (setvar "osmode" osmant) ) ) ) ) (princ) ) (defun c:WP-count (/ pl lstent points conj ptx creaMTEXT altura) (defun creaMTEXT (texto altura / vlaEnt) (setq vlaEnt (vla-AddMText (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (vlax-3d-point ptx) 50 (strcat "Count:\\P" (itoa (sslength conj))))) (vlax-put-property vlaEnt "Height" altura) ) (if (setq pl (car (entsel "\nSelect border polyline..."))) (if (= "LWPOLYLINE" (cdr (assoc 0 (setq lstent (entget pl))))) (setq points (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) lstent ) ) ) ) ) (if points (progn (if (not altura1) (setq altura (getreal "\nHeight TEXT: ")) (setq altura (getreal (strcat "\nHeight TEXT (or ENTER for <" (rtos altura1 2 2) ">): "))) ) (if (not altura) (if altura1 (setq altura altura1) ) (setq altura1 altura) ) ) ) (if (and points altura (setq conj (ssget "_cp" points '((0 . "CIRCLE"))))) (if (setq ptx (getpoint (strcat "\nPick insertion point for objects number text <" (itoa (sslength conj)) "> (right click or ENTER for skip)..."))) (vla-AddText (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (itoa (sslength conj)) (VLAX-3D-POINT ptx) altura) ) ) (princ) )1 point
-
As for what you say about AutoCAD 2015, it seems strange to me. Although I have heard somewhere that this version of AutoCAD does strange things.1 point
-
1 point
-
As for '(*radius 10.0)', you should put a space between '*' and 'radius': '(* radius 10.0)'1 point
-
1 point
-
In the last code I have attached last time are the 2 updated commands. Copy them again and test them to make sure what you tell me. In 'WP-count' the selection mode is updated and works correctly. If you want to customize the text content you will have to modify the parameter '(itoa (sslenght conj))' of the function '(vla-AddText...) ' As for the pattern, so that the distribution of the circles is square and not rhomboidal, simply divide by 2 the parameter 'step' when the 'y' of the loop '(while (<= y maxy) ' is increased. '(setq y (+ y (/ step 2.0)))'1 point
-
The way I make custom dcl's is that I use say Multi getvals to make a dcl file, I change the code. (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w")) (setq fo (open (setq fname "D"\\acadtemp\\dcltest.dcl") "w")) Then I can see the dcl code I would then add a new row which would be Radio buttons for the "Hor" or "Ver" as choices. Lastly I use a lisp by rlx to convert the dcl code to lisp code and add to the program. Ok an easy answer here is Multi radio buttons.lsp look at the top of code and you will see a Yes or No option change to say HOR & VER. This will return the string "HOR" or "VER" so use with the IF. Multi radio buttons.lsp1 point
-
That's it. Now it works. The code should work in AutoCAD 2015. I've tested it and it works. ACD2015.mp41 point
-
Wait I don't know what's going on I edited the code but the website hasn't updated it again I'll try again.1 point
-
I just updated the code with the necessary changes. Please check if everything is working properly1 point
-
Can you post what you have so far? There is also Taper Faces and Rotate Faces that come in handy. What type of 3D design are you doing? Cad64 is experienced in a good deal of 3D applications and has a very good YouTube page. I learned most of my techniques for 3D by trial and error and watching videos and reading tutorials once the internet was useful in those endeavors to refine and speed up my methods..1 point
-
In the bottom right corner of AutoCAD, click on the upside down triangle. Check that there is a tick next to Paper/Model. If there is not, then select it. Now at the bottom of your screen, where ORTHO, OSNAP, etc is there will be a button which will say PAPER or MODEL depending on if you are in paperspace or modelspace/viewport. If you are in a viewport and it says model, then just click it and it will change to paper and take you out of the viewport. Let me know if you are unsure about this and I will post a screenshot. Alternatively, type PSPACE at the command line.1 point