Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/27/2026 in all areas

  1. @Nikon The "COND" statement will stop as soon as it meets the criteria for the square area range, so if something else meets the that area range before getting to your desired state, it will never get there. You will have to do a different comparison that is unique to the criteria. Maybe to change the criteria for the conditional statement to comparing the Length and width specifically, rather than with the area, or a combination of the area and the width, or something else, like a unique layer or color. Maybe something like this instead (you can alter to suit the fudge factor for the viewport height and width): (cond ((and (> 290.0 ViewPortHeight 300.0) (> 600.0 ViewPortWidth 650.0));; Compare the width and height directly! (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "UserDefinedMetric (297.00 x 630.00мм)") ) ((and (> 290.0 ViewPortHeight 300.0) (> 835.0 ViewPortWidth 845.0)) (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "UserDefinedMetric (297.00 x 841.0мм)") ) ... ;; Repeat for all desired sizes ) NOTE: You would also have to do both a landscape version and a Portrait version if you need both. Perhaps a bit more sophisticated comparison: (cond ((or (and (> 290.0 ViewPortHeight 300.0) (> 600.0 ViewPortWidth 650.0)) (and (> 290.0 ViewPortWidth 300.0) (> 600.0 ViewPortHeight 650.0)) ) (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "UserDefinedMetric (297.00 x 630.00мм)") ) ((or (and (> 290.0 ViewPortHeight 300.0) (> 835.0 ViewPortWidth 845.0)) (and (> 290.0 ViewPortWidth 300.0) (> 835.0 ViewPortHeight 845.0)) ) (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "UserDefinedMetric (297.00 x 841.0мм)") ) ... ; Repeat for all desired sizes (T (vla-put-ConfigName Layout "None")) ; Default to No plotter for non-standard sizes ) NOTE: I can't test this directly without a "real world" sample drawing to compare, along with your pc3 file, so I'm trying to give you the knowledge to do it yourself, which is preferrable anyway.
    2 points
  2. Thanks, I'll try it. There is another option, but it does not work for all formats. ;; A3x3 (420x891) ((and (<= SideS 425) (<= SideL 896)) (vla-put-CanonicalMediaName Layout "UserDefinedMetric (891.00 x 420.00мм)"))
    1 point
  3. just FYI for @ScottMC That while loop is running 1000's times a sec and is intended to only pause waiting for user input to be completed. Can be simplified to this. (while (> (getvar 'CMDACTIVE) 0) (Command "\\") ) Another option would be to use grread and grdraw to show a visualization of a circle but not actually add it to the drawing (in red). Tho I found out it can only draws lines and you need to trick it to make segmented circles. will post something later tonight. -- Edit This doesn't have any command so doesn't need above code or to toggle CMDECHO. ;;----------------------------------------------------------------------;; ;; 2 Point Circle ;; grcircle function from https://lee-mac.com/circletangents.html (defun c:C2 (/ *error* cr P1 P2 P3 rad ev oe os doc) (defun *error* (msg) (setvar 'OSMODE os) (vla-endundomark doc) (princ (strcat "\n" msg)) ) (defun grcircle (cen rad / ang) (setq ang 0.0) (repeat ctan:res (grdraw (polar P3 ang rad) (polar P3 (setq ang (+ ang ctan:inc)) rad) 1) ) ) (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-startundomark doc) (setq ctan:res 40 ;; arc resolution (int > 0) ctan:2pi (+ pi pi) ctan:inc (/ ctan:2pi ctan:res) ) (setq os (getvar 'OSMODE)) (while (and (setvar 'OSMODE (boole 7 os 512)) (setq P1 (getpoint "\nSpecify 1st Point of 2P.Circle: ")) ) (setvar 'osmode os) (prompt "\nSpecify 2nd Point: ") (while (progn (setq ev (grread t 13 0)) (= (car ev) 5) ) (redraw) (setq P2 (cadr ev)) (setq rad (/ (distance P1 P2) 2.0)) (setq P3 (Polar P1 (angle P1 P2) rad)) (grcircle P3 rad) ) (if (= (car ev) 3) (progn (setq P2 (cadr ev)) (setq rad (/ (distance P1 P2) 2.0)) (setq P3 (polar P1 (angle P1 P2) rad)) (setq cr rad) (redraw) (princ (strcat "\n Coordinates: " (setq C2:pp (strcat (rtos (car P3) 2 4) "," (rtos (cadr P3) 2 4) "," (rtos (caddr P3) 2 4))) "\n Diameter: " (rtos (* cr 2) 2 4) " | Radius: " (rtos cr 2 4))) (entmakex (list '(0 . "POINT") (cons 10 P3))) (entmakex (list '(0 . "POINT") (cons 10 P2))) (entmakex (list '(0 . "CIRCLE") (cons 10 P3) (cons 40 cr) (cons 8 (getvar "CLAYER")))) ) ) ) (setvar 'cmdecho 1) (vla-endundomark doc) (princ) )
    1 point
  4. Thanks PK for finding that. Something I've never found or got direct connection to error but now will have that as an understood rule. Will certainly look for that in my troubleshooting.
    1 point
  5. @ScottMC I don't recommend you put the OSMODE change in the CMDACTIVE loop. Here is how I would do it; tested this and it works perfectly. (defun c:C2 (/ cr el *error* fp oe os p p2) (defun *error* (msg) (if oe (setvar "cmdecho" oe)) (if os (setvar "osmode" os)) (vla-endundomark (vla-get-activedocument (vlax-get-acad-object))) (princ (strcat "\n" msg)) ) (vla-startundomark (vla-get-activedocument (vlax-get-acad-object))) (setq oe (getvar "cmdecho") os (getvar "osmode") ) (setvar "cmdecho" 0) (while (and (setvar 'osmode (boole 7 os 512)) (setq fp (getpoint "\nSpecify 1st Point of 2P.Circle: ")) ) (command "._Circle" "_2P" "_non" fp "_per");; Add "PER" to overide OSNAP here. (princ "\nSecond Point: ") (while (= (logand (getvar "cmdactive") 1) 1) (command pause) ) (setvar "osmode" os) (setq el (entget (entlast)) p (trans (cdr (assoc 10 el)) (cdr (assoc 210 el)) 1) p2 (getvar "lastpoint") cr (getvar "circlerad") ) (entdel (entlast)); Delete the Circle (princ (strcat "\n Coordinates: " (setq C2:pp ;; Global Variable "C2:pp" (strcat (rtos (car p) 2 4) "," (rtos (cadr p) 2 4) "," (rtos (caddr p) 2 4) ) ) "\n Diameter: " (rtos (* cr 2) 2 4) " | Radius: " (rtos cr 2 4) "\n" ) ) (entmakex (list (cons 0 "POINT") (cons 10 p))) (entmakex (list (cons 0 "POINT") (cons 10 p2))) (entmakex (list (cons 0 "CIRCLE") (assoc 10 el) (assoc 8 el) (assoc 40 el))) ; Recreate the Circle ) (setvar "cmdecho" oe) (vla-endundomark (vla-get-activedocument (vlax-get-acad-object))) (princ) ) If you don't want PERP to be the only snap available, then try your method, but before the CMDACTIVE loop: (command ".circle" "2p" 1st) (setvar 'cmdecho 1) (setvar 'osmode (boole 7 (getvar 'osmode) 128)) ;; added 'perp (while (= 1 (logand 1 (getvar 'cmdactive))) (command "\\") )
    1 point
  6. hi. sorry to ask. Did you use Vibe coding on this? Coz I notice formatting similarities
    1 point
×
×
  • Create New...