Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/08/2025 in Posts

  1. You can actually calculate it, here is the code (you can change it for your purposes): (setq ptlist (mapcar 'cdr (vl-remove-if-not (function (lambda (x) (= (car x) 10))) (setq ent (entget (car (entsel "\nSelect the line:")))))) ;; point list sum_x 0 sum_y 0 vertices (cdr (assoc 90 ent)) ;; number of vertices for LWPOLYLINE ) (foreach pt ptlist (setq sum_x (+ sum_x (car pt))) ;; sum only the X vertices values ) (foreach pt ptlist (setq sum_y (+ sum_y (cadr pt))) ;; sum only the Y vertices values ) (setq sum_x (/ sum_x vertices) ;; dividing the total sum X by the number of vertices sum_y (/ sum_y vertices) ;; dividing the total sum Y by the number of vertices pt (list sum_x sum_y) ;; geometric center ) Below are the pictures with geometric center for open and closed polyline (picture 1 open, picture 2 closed). Picture 1. Picture 2. This is true. Best regards.
    3 points
  2. This (ssget '((0 . "TEXT") (-4 . "<>") (40 . 3.5))) should work. You can change "TEXT" to "*TEXT" to also capture MText Though looking at the code you have, I am assuming that is just a snippet of what you want to do. Here are a couple of hints: (defun c:pru ( / ss ) ;;Yup localised variables, C: prompt, all good (setq ss (ssget '((0 . "TEXT") (-4 . "<>") (40 . 3.5))) ) ;; ADDED (SETQ SS ... ) so that you can use the selection set later (princ (sslength ss)) ;; Added this in to show the result of the selection set (princ) ;;Exit quietly )
    2 points
  3. Only the geometric center is available for closed areas, since open polylines have no area and therefore no true center. If it’s just a line, the "geometric center” is the midpoint.
    2 points
  4. At home I have some file compare programs, Notepad++ with the Compare plug-in as well. IIRC, there are some online as well, WinMerge I think is one of my programs, I use AntiTwin to find duplicate files, it may have a compare function. So while everyone is doing there jobs, if YOU have the time, you might could compare the file and see what all is different. At least that will be a start, maybe I can talk IT into putting one of those programs on my work computer. I used to have a program from CabloFil, not sure if they still have anything for doing cable trays in AutoCAD. Here it is... Cable Management 3D Modeling Tools | Legrand I haven't done a cable tray in ages, so not sure what all it does.
    1 point
  5. Try this: ;; Modified by DV. Visit my page at: https://lispautocad.gumroad.com/ (defun c:PRU (/ ss) (if (setq ss (ssget '((0 . "TEXT,MTEXT") (-4 . "<>") (40 . 3.5)))) (progn (sssetfirst nil ss) (princ (strcat "\nSelecting: " (itoa (sslength ss)) " objects.")) ) (princ "\nNo Object.") ) (princ) )
    1 point
  6. Here is the code @mhy3sx, based on your original file. I've modified a few lines using a different approach, but the result remains the same. If you find this helpful, feel free to visit my page where I share tools designed to improve efficiency and save time, as effortlessly as enjoying a cup of coffee: https://lispautocad.gumroad.com/ ;; Modified by DV. Visit my page at: https://lispautocad.gumroad.com/ (defun c:Stair2D (/ p1 p2 ent start_pt end_pt mid_pt line_length circle_diameter num_steps i move_vec array_vec step_vec last_start_pt last_end_pt last_mid_pt mid1mid2_vec mid1mid2_length unit_vec perp_vec arrow_p1 arrow_p2 arrow_p3) (vl-load-com) (setvar "CMDECHO" 0) (command "._UNDO" "_BEGIN") (if (not (tblsearch "LAYER" "STAIR")) (command "_layer" "_m" "STAIR" "_c" "90" "" "") ) (setvar "CLAYER" "STAIR") (princ "\nSelect the first LINE of the staircase: ") (while (not (setq ent (ssget ":S" '((0 . "LINE"))))) (princ "\nTry again!! ") ) (command "._CHANGE" ent "" "_P" "_LA" "STAIR" "") (setq ent (ssname ent 0)) (setq ent_data (entget ent)) (setq start_pt (cdr (assoc 10 ent_data))) (setq end_pt (cdr (assoc 11 ent_data))) (setq mid_pt (mapcar '(lambda (a b) (/ (+ a b) 2.0)) start_pt end_pt)) (setq line_length (distance start_pt end_pt)) (setq circle_diameter (/ line_length 10.0)) (princ "\nSelect the start of the staircase: ") (setq p1 (getpoint)) (princ "\nSelect the end of the staircase: ") (setq p2 (getpoint p1)) (initget 7) (setq num_steps (getint "\nEnter the number of steps: ")) (setq array_vec (mapcar '- p2 p1)) (setq step_vec (mapcar '(lambda (x) (/ x num_steps)) array_vec)) (setq i 1) (while (<= i num_steps) (setq move_vec (mapcar '(lambda (x) (* x i)) step_vec)) (command "._COPY" ent "" "_non" (list 0 0 0) "_non" move_vec) (setq i (1+ i)) ) ;; Circle and arrow line (command "._CIRCLE" mid_pt (/ circle_diameter 2.0)) (setq last_start_pt (mapcar '+ start_pt (mapcar '(lambda (x) (* x num_steps)) step_vec))) (setq last_end_pt (mapcar '+ end_pt (mapcar '(lambda (x) (* x num_steps)) step_vec))) (setq last_mid_pt (mapcar '(lambda (a b) (/ (+ a b) 2.0)) last_start_pt last_end_pt)) (command "._LINE" mid_pt last_mid_pt "") (setq mid1mid2_vec (mapcar '- last_mid_pt mid_pt)) (setq mid1mid2_length (distance mid_pt last_mid_pt)) (if (> mid1mid2_length 0) (progn (setq unit_vec (mapcar '(lambda (x) (/ x mid1mid2_length)) mid1mid2_vec)) (setq perp_vec (list (- (cadr unit_vec)) (car unit_vec) 0.0)) (setq arrow_p1 (mapcar '+ last_mid_pt (mapcar '(lambda (x) (* x 0.10 mid1mid2_length)) unit_vec))) (setq arrow_p2 (mapcar '+ last_mid_pt (mapcar '(lambda (x) (* x -0.15 mid1mid2_length)) perp_vec))) (setq arrow_p3 (mapcar '+ last_mid_pt (mapcar '(lambda (x) (* x 0.15 mid1mid2_length)) perp_vec))) (command "._LINE" arrow_p1 arrow_p2 "") (command "._LINE" arrow_p1 arrow_p3 "") ) ) (command "._UNDO" "_END") (setvar "CMDECHO" 1) (setvar "CLAYER" "0") (princ) )
    1 point
  7. Like @CyberAngel use Layiso & Layuniso, check settings I use all off rather than fade.
    1 point
  8. Another way to do that is to Hide the geometry you don't want. You can bring it back as soon as you finish. Edit: or just leave it hidden, it will show up when you load the drawing again.
    1 point
  9. Depending on what your doing you can call transparent snaps, ie change the osnap setting in a command. Eg Line '47 pickpoint Note the apostrophe in front of the 47. A lisp defun has been made that is autoloaded. This resets the snaps for the pick point. (defun C:15 ()(setvar "osmode" 15359)) ; sets all snaps on (defun C:47 ()(setvar "osmode" 47)) (defun C:99 ()(setvar "osmode" 99)) (defun C:8 ()(setvar "osmode" 8)) (defun C:9 ()(setvar "osmode" 9)) (defun C:0 ()(setvar "osmode" 0)) Don't forget m2p for middle of two points
    1 point
×
×
  • Create New...