Leaderboard
Popular Content
Showing content with the highest reputation since 03/19/2026 in all areas
-
You must've copied the changes into your code incorrectly. "RH: DXF" is already defined in your original code. (defun rh:dxf (code lst) (cdr (assoc code lst))) Attached is your original code with @mhupp's change: (defun rh:dxf (code lst) (cdr (assoc code lst))) (defun c:aa ( / cmde ent e_typ e_lst area vtx x_lst y_lst z_lst x_pt y_pt z_pt c_lst v_lst ss sum) (cond ( (/= 0 (getvar 'cmdecho)) (setq cmde (getvar 'cmdecho)) (setvar 'cmdecho 0) ) ) (while (setq ss (ssget "_+.:E:S" '((0 . "POLYLINE,LWPOLYLINE") (-4 . "<OR") (70 . 1) (70 . 3) (70 . 5) (-4 . "OR>") ) )) (setq ent (ssname ss 0) e_typ (rh:dxf 0 (setq e_lst (entget ent))) area (getpropertyvalue ent "area") v_lst nil ) (cond ( (= e_typ "POLYLINE") (setq ent (entnext ent) vtx (rh:dxf 10 (entget ent)) ) (if (< (length vtx) 3) (setq vtx (reverse (cons 0.0 (reverse vtx))))) (while (/= "SEQEND" (cdr (assoc 0 (entget ent)))) (setq v_lst (cons vtx v_lst) ent (entnext ent) vtx (rh:dxf 10 (entget ent)) ) (if (< (length vtx) 3) (setq vtx (reverse (cons 0.0 (reverse vtx))))) ) (setq x_pt (/ (apply '+ (mapcar '(lambda (x) (car x)) v_lst)) (length v_lst)) y_pt (/ (apply '+ (mapcar '(lambda (x) (cadr x)) v_lst)) (length v_lst)) ) (if (= (setq sum (apply '+ (mapcar '(lambda (x) (caddr x)) v_lst))) 0.0) (setq z_pt 0.0) (setq z_pt (/ sum (length v_lst))) ) ) ( (= e_typ "LWPOLYLINE") (setq z_pt (rh:dxf 38 e_lst)) (foreach pr e_lst (if (= (car pr) 10) (setq v_lst (cons (cdr pr) v_lst))) ) (setq x_pt (/ (apply '+ (mapcar '(lambda (x) (car x)) v_lst)) (length v_lst)) y_pt (/ (apply '+ (mapcar '(lambda (x) (cadr x)) v_lst)) (length v_lst)) ) ) ) (setq c_lst (list x_pt y_pt z_pt)) (entmakex (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (cons 10 c_lst) (cons 40 (getvar 'textsize)) (cons 71 5) (cons 72 5) (cons 1 (strcat (rtos (/ area 1000000.0) 2 2) "m" (chr 0178))) ; (cons 1 (strcat (rtos (/ area 1000000.0) 2 2) "m²")) ; (cons 1 (rtos (/ area 1000000.0) 2 3)) ; If you don't need the suffix "m²" ) ) ) (if cmde (setvar 'cmdecho cmde)) )2 points
-
chr instead of string. (cons 1 (strcat (rtos (/ area 1000000.0) 2 2) "m" (chr 0178))) also might be the font your using. https://www.cadtutor.net/forum/topic/75383-text-ascii/#findComment-5962262 points
-
(defun rh:dxf (code lst) (cdr (assoc code lst))) (defun c:aa ( / cmde ent e_typ e_lst area vtx x_lst y_lst z_lst x_pt y_pt z_pt c_lst v_lst ss sum sz) (cond ( (/= 0 (getvar 'cmdecho)) (setq cmde (getvar 'cmdecho)) (setvar 'cmdecho 0) ) ) (while (setq ss (ssget "_+.:E:S" '((0 . "POLYLINE,LWPOLYLINE") (-4 . "<OR") (70 . 1) (70 . 3) (70 . 5) (-4 . "OR>") ) )) (setq ent (ssname ss 0) e_typ (rh:dxf 0 (setq e_lst (entget ent))) area (getpropertyvalue ent "area") v_lst nil ) (cond ( (= e_typ "POLYLINE") (setq ent (entnext ent) vtx (rh:dxf 10 (entget ent)) ) (if (< (length vtx) 3) (setq vtx (reverse (cons 0.0 (reverse vtx))))) (while (/= "SEQEND" (cdr (assoc 0 (entget ent)))) (setq v_lst (cons vtx v_lst) ent (entnext ent) vtx (rh:dxf 10 (entget ent)) ) (if (< (length vtx) 3) (setq vtx (reverse (cons 0.0 (reverse vtx))))) ) (setq x_pt (/ (apply '+ (mapcar '(lambda (x) (car x)) v_lst)) (length v_lst)) y_pt (/ (apply '+ (mapcar '(lambda (x) (cadr x)) v_lst)) (length v_lst)) ) (if (= (setq sum (apply '+ (mapcar '(lambda (x) (caddr x)) v_lst))) 0.0) (setq z_pt 0.0) (setq z_pt (/ sum (length v_lst))) ) ) ( (= e_typ "LWPOLYLINE") (setq z_pt (rh:dxf 38 e_lst)) (foreach pr e_lst (if (= (car pr) 10) (setq v_lst (cons (cdr pr) v_lst))) ) (setq x_pt (/ (apply '+ (mapcar '(lambda (x) (car x)) v_lst)) (length v_lst)) y_pt (/ (apply '+ (mapcar '(lambda (x) (cadr x)) v_lst)) (length v_lst)) ) ) ) (setq c_lst (list x_pt y_pt z_pt)) (if(not sz) (progn (vla-getboundingbox (vlax-ename->vla-object ent) 'MinPT 'MaxPT) (setq p1 (vlax-safearray->list MinPT) p2 (vlax-safearray->list MaxPT)) (setvar 'textsize (* 0.05 (distance p1 p2))) (setq sz t) ) ) (entmakex (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (cons 10 c_lst) (cons 40 (getvar 'textsize) ) (cons 71 5) (cons 72 5) (cons 1 (strcat (rtos (/ area 1000000.0) 2 2) "m\U+00B2")) ) ) ) (if cmde (setvar 'cmdecho cmde)) )1 point
-
(defun rh:dxf (code lst) (cdr (assoc code lst))) (defun c:aa ( / cmde ent e_typ e_lst area vtx x_lst y_lst z_lst x_pt y_pt z_pt c_lst v_lst ss sum) (cond ( (/= 0 (getvar 'cmdecho)) (setq cmde (getvar 'cmdecho)) (setvar 'cmdecho 0) ) ) (while (setq ss (ssget "_+.:E:S" '((0 . "POLYLINE,LWPOLYLINE") (-4 . "<OR") (70 . 1) (70 . 3) (70 . 5) (-4 . "OR>") ) )) (setq ent (ssname ss 0) e_typ (rh:dxf 0 (setq e_lst (entget ent))) area (getpropertyvalue ent "area") v_lst nil ) (cond ( (= e_typ "POLYLINE") (setq ent (entnext ent) vtx (rh:dxf 10 (entget ent)) ) (if (< (length vtx) 3) (setq vtx (reverse (cons 0.0 (reverse vtx))))) (while (/= "SEQEND" (cdr (assoc 0 (entget ent)))) (setq v_lst (cons vtx v_lst) ent (entnext ent) vtx (rh:dxf 10 (entget ent)) ) (if (< (length vtx) 3) (setq vtx (reverse (cons 0.0 (reverse vtx))))) ) (setq x_pt (/ (apply '+ (mapcar '(lambda (x) (car x)) v_lst)) (length v_lst)) y_pt (/ (apply '+ (mapcar '(lambda (x) (cadr x)) v_lst)) (length v_lst)) ) (if (= (setq sum (apply '+ (mapcar '(lambda (x) (caddr x)) v_lst))) 0.0) (setq z_pt 0.0) (setq z_pt (/ sum (length v_lst))) ) ) ( (= e_typ "LWPOLYLINE") (setq z_pt (rh:dxf 38 e_lst)) (foreach pr e_lst (if (= (car pr) 10) (setq v_lst (cons (cdr pr) v_lst))) ) (setq x_pt (/ (apply '+ (mapcar '(lambda (x) (car x)) v_lst)) (length v_lst)) y_pt (/ (apply '+ (mapcar '(lambda (x) (cadr x)) v_lst)) (length v_lst)) ) ) ) (setq c_lst (list x_pt y_pt z_pt)) (vla-getboundingbox (vlax-ename->vla-object ent) 'MinPT 'MaxPT) (setq p1 (vlax-safearray->list MinPT) p2 (vlax-safearray->list MaxPT)) (entmakex (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (cons 10 c_lst) (cons 40 (* 0.02 (distance p1 p2)) );(getvar 'textsize)) (cons 71 5) (cons 72 5) (cons 1 (strcat (rtos (/ area 1000000.0) 2 2) "m\U+00B2")) ) ) ) (if cmde (setvar 'cmdecho cmde)) )1 point
-
Are you saying you want say a A3 sheet 420x297 but with 3 viewports, that can be done. To have a oversize sheet does not make sense to me. You just set up the sheet details and the location of each viewport, not hard to do. ("A3" "0,20" "140,190" "140,20" ""280,190" and so on)1 point
-
Hi Steven, spot on! The LISP definitely flags raw geometry changes, not design intent. I actually use it as a "first pass" safety net. It's much faster to let the script cloud everything that moved and simply delete the few "false positives" (like lines stretched for spacing) than to manually hunt for actual design changes. For the overlapping issue: the clouds are standard polylines on a dedicated layer. You can easily grip-stretch them out of the way, or use DFCT beforehand to increase the padding so they draw looser. It doesn't replace a drafter's eye, but it definitely handles the heavy lifting of finding the changes first! Thanks for checking it out.1 point
-
NOTE: If your viewport frames do not match the paper size (for example: you put your borders in Paperspace and you only use the area internal to the border), Then use the area of the viewport frame to determine the size range, not the paper size.1 point
-
Are these the actual names of the Paper sizes in the pc3 file? The squares in your example file are just the paper sizes. You need to know the Frame layer, and the size range of the Frames that create your viewports. In any case - you should have all the information you need to do it yourself. as I said in the above to lay it out more clearly: 1) You need a range of AREA to be within on the frames. For example, on your "A4x3", (297 x 630) = 187110. Your range for the "square" variable should be a min and max with this value in the middle, such as 187110 - 10000 = 177110 "(> Square 177110)" and 187110 + 10000 = 197110 "(< Square 197110)" 2) each added condition should have the exact name of the Custom paper size: ((and (> Square 177110) (< Square 197110))(vla-put-ConfigName Layout "DWG To PDF.pc3")(vla-put-CanonicalMediaName Layout "_A4x3_(297.00_x_630.00_MM)")) ALSO: 3) You must have a unique Layer for the Frame polylines or blocks, something like "MyPaperSizeFrameLayer", or anything, as long as it is unique to the frames.1 point
-
The condition lines I added were just examples of how to add more sizes. As long as you know the areas and the name of the paper size, you should be able to add them. The "Square" variable as i understand it, is the min and max AREA of the frame you select (Length x Width), for the condition to select the paper size. This depends on what you are selecting for the frame to define the paper size. How would I know, if I don't have an example of what you are selecting?1 point
-
When this thread was started in 2014, it absolutely was the way AutoCAD worked, SELECTIONOFFSCREEN is only available in AutoCAD 2018 and newer. This has already been mentioned in this thread as well.1 point
-
@Nikon While I don't know this routine, and don't recognize the Paper Sizes you have specified. The change would have to do with this section I think (see below). I added a couple condition lines for standard layouts "ISO full bleed 2A0" and "ISO full bleed 4A0" that are in my standard "DWG to PDF.PC3" file. I don't know what determines the area of the viewports though, (it seems that it is an object you select), so I am guessing at the area range of the viewport sizes. (cond ((and (> Square 59251) (< Square 65488)) (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "ISO_full_bleed_A4_(297.00_x_210.00_MM)")) ((and (> Square 118503) (< Square 130977)) (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "ISO_full_bleed_A3_(420.00_x_297.00_MM)")) ((and (> Square 237006) (< Square 261954)) (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "ISO_full_bleed_A2_(594.00_x_420.00_MM)")) ((and (> Square 474012) (< Square 523908)) (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "ISO_full_bleed_A1_(841.00_x_594.00_MM)")) ((and (> Square 948024) (< Square 1047816)) (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "ISO_full_bleed_A0_(841.00_x_1189.00_MM)")) ((and (> Square 1949898) (< Square 2049898)) (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "ISO_full_bleed_2A0_(1189.00_x_1682.00_MM)")) ((and (> Square 3949796) (< Square 4049796)) (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "ISO_full_bleed_4A0_(1682.00_x_2378.00_MM)")) (T (vla-put-ConfigName Layout "None")) ; Default to No plotter for non-standard sizes )1 point
-
They are just FIELDS referencing a Position Marker as shown in the image of the Field Dialog Box you posted. They are just Multileaders with the fields added into the MText. This is just a good use of Multileaders, no need for any blocks.1 point
-
try this (cons 1 (strcat (rtos (/ area 1000000.0) 2 2) "m\U+00B2"))1 point
-
Hi everyone, I want to share a LISP tool I recently developed called SyncBlock. If you work with architectural or MEP backgrounds, you probably deal with this nightmare constantly: You have a Master Block (A), and several child blocks (B, C, D) that were copied from A but have some layers deleted to show different details. When the Master Block updates, synchronizing those child blocks without ruining their specific layer visibility—and without them flying off to random coordinates because their base points are all set to (0,0,0)—is a huge pain. To solve this, I wrote a script that does the following: 1. You select the Master Block. 2. You window-select the target blocks. 3. The script reads which layers are currently active in the target block, clears it, and pulls only those matching layers from the Master Block. The Magic (Consensus Voting Algorithm): The biggest challenge was alignment. Standard Bounding Box methods fail if you delete half a room or add a dimension in the child block. To fix this, the script uses a "Consensus Voting" approach. It gathers all valid geometry centers in both blocks, pairs them up, calculates the displacement vectors (dX, dY), and lets them "vote." The offset with the overwhelming majority wins. This ensures pixel-perfect alignment even if the child block is heavily trimmed! GitHub Repository: https://github.com/beastt1992/SyncBlock-AutoCAD The code avoids copying Hatches to prevent associativity crashes, and it safely handles older AutoCAD versions (like 2014) by using pure English prompts to avoid ANSI/UTF-8 encoding issues. I’d love for you guys to test it out on your messy real-world drawings! Any feedback, bug reports, or suggestions for improvement are highly appreciated. Cheers!1 point
-
I don't work with an architectural background so my nightmares are somewhat different than yours (most of them are about my mother in law or my sister in law) but thank you for sharing. High Lee , oh sorry , highly appreciated1 point
-
At one time P-F required students to submit a separate .dwg file for each plate. I don't see any reason why you can't use layouts. Your advisor could probably answer the question.1 point
-
Welcome to Cadtutor. What you are offering is not a new solutions this have been around for me say 17 years, for where I worked. But I have something extra for you, once you make the PDF's as single pdf's you can join them back into one, done this for 88 layouts but code looks for PDF's. It uses Ghostscript to rejoin the pdf's. Ghostscript is a free product and has lots of features. The code is ran via lisp. The code attached also allows for a selection of layouts it has the Ghostscript code in it. You will need to edit the version of Ghostscript and its location. A more advanced version checks for different company title blocks, eg landscape V's portrait. Like others I would push for using layouts a much better way as you can take advantage of the viewport scale, I have multi code for making multiple layouts at scale matching your model space. Multi GETVALS.lsp plotA3Pdfrange2.lsp1 point
-
@Steven P Not easy to notice, but he did give a link to the routine: https://github.com/beastt1992/autocad-batch-plot I agree that layouts should be used.1 point
-
So post the LISP so we can give feedback - it is easier to reference if the LISP is in the same thread as the comments and questions Though I might be tempted to say change the system and get the draughters to use paperspace for what it is meant for. (haven't had the paperspace / modespace discussion on here for a while now....)1 point
-
1 point
-
1 point
-
Alright, another Penn Foster student here. Big shocker there, I know. I put all my drawings from model space in to sheets but I lost all my dimensions and some of my furniture blocks. I double checked to be sure I didn't have any frozen layers, nothing is in def points, they're in correct layers, I ran an audit and it found and fixed 0 errors. I'm really new to all this auto cad stuff but apparently my work thinks I need it even though ill never use it. I'm not even ALOUD to have it on my computer at work...lol Any help would be greatly appreciated Flr-B.dwg Flr-1.dwg FLR-2.dwg1 point
