Leaderboard
Popular Content
Showing content with the highest reputation on 09/17/2024 in all areas
-
That is probably the reason just like I wrote, last inserted is first in list, and yes this happens here because you have multiple rows. Blocks 1, 4, 7 are not sorted between them. Here is multiple sorting, form left to right, and top to bottom, try this. With block numbering you have more flexibility, but again this is simpler here because block doesn't need to be edited. (vl-load-com) (defun c:PDFA1 (/ lst lst_sort lst1 lst2 n Ysort dwg file hnd i len llpt lst mn mx ss tab urpt) (setq lst nil) (if (setq ss (ssget "_X" '((0 . "INSERT") (2 . "PDFA1")))) (progn (repeat (setq i (sslength ss)) (setq hnd (ssname ss (setq i (1- i))) tab (cdr (assoc 410 (entget hnd))) lst (cons (list hnd (cdr (assoc 10 (entget hnd))) tab) lst) ) ) (setq lst_sort nil) (setq n 0) (while (< n (length lst)) (if (not (vl-remove-if-not '(lambda (y) (equal (cadr (cadr (nth n lst))) y 0.01)) Ysort)) (setq Ysort (cons (cadr (cadr (nth n lst))) Ysort)) );if (setq n (1+ n)) );while (setq Ysort (vl-sort Ysort '(lambda (x y) (> x y)))) (setq n 0) (while (< n (length Ysort)) (setq lst1 (vl-remove-if-not '(lambda (x) (equal (nth n Ysort) (cadr (cadr x)) 0.01)) lst)) (setq lst2 (vl-sort lst1 '(lambda (x y) (< (car (cadr x)) (car (cadr y)))))) (setq lst_sort (append lst_sort lst2)) (setq n (1+ n)) );while (setq i 0) (foreach x lst_sort (setq file (strcat (getvar 'DWGPREFIX) (substr (setq dwg (getvar 'DWGNAME)) 1 (- (strlen dwg) 4)) "-" (itoa (setq i (1+ i))) ".pdf" ) ) (if (findfile file) (vl-file-delete file) ) (vla-getboundingbox (vlax-ename->vla-object (car x)) 'mn 'mx) (setq llpt (vlax-safearray->list mn) urpt (vlax-safearray->list mx) len (distance llpt (list (car urpt) (cadr llpt))) ) (command "-plot" "yes" (car x) "DWG TO PDF.PC3" "ISO full bleed A1 (841.00 x 594.00 MM)" "Millimeters" "Landscape" "No" "Window" llpt urpt "Fit" "Center" "yes" "Standard-A1.ctb" "yes" "" ) (if (/= (caddr x) "Model") (command "No" "No" file "no" "Yes") (command file "no" "Yes" ) ) ) ) ) (princ) )2 points
-
@Saxlle This line : (command "_pedit" "_M" ss3 "" "J" "0" "") won't work well if you don't set before it : (setvar (quote peditaccept) 1) I always use setting it before with (setq pea (getvar (quote peditaccept))) => (setvar (quote peditaccept) 1) And at the end resetting it to starting value : (setvar (quote peditaccept) pea)1 point
-
WOW It worked great Exactly what I was looking for Thanks a lot1 point
-
What are the spine shapes like? You might save a few minutes with a LISP on a simple shape but sometimes drawing over it will give you more accurate and better results. To do this well you need to convert the spline to exploded polylines - short straight lines, to assess which of these lines form arcs and curves, replace these arc and curve chords with arcs, combine the whole lot to a polyline.. which is quite a lot. Arcs are the trickiest to assess, the original drawing might have been polyline converted to splines so the arcs are consistent throughout, some are drawn as splines and the radius changes through the curve.... trickier! However the above LISP will give a fair estimation.1 point
-
Hi @pondpepo9, Try with this modification. (defun c:spl2pl ( / ss i ent ss3 ss2 obj cpcount j ) (princ "\n Select spline to convert to pline : ") (setq ss (ssget '((0 . "SPLINE")))) (setq i 0) (setq ss3 (ssadd)) (repeat (sslength ss) (setq ent (ssname ss i)) (command "_explode" ent "") (setq ss2 (ssget "_P")) (setq j 0) (repeat (sslength ss2) (setq ent2 (ssname ss2 j)) ;;; (setq obj (vlax-ename->vla-object ent2)) -> Autocad 2024 LT doesn't support a "vla-, vlax-, and vlr- functions" (setq cpcount (cdr (assoc 73 (entget ent2)))) ;; this will replace code from above and bottom ;;; (setq cpcount (vlax-get-property obj 'Numberofcontrolpoints)) -> there is a "vlax-" function (command "_SPLINEDIT" ent2 "_P" cpcount "") (ssadd (entlast) ss3) (setq j (+ j 1)) ) (setq i (+ i 1)) ) (if (> (sslength ss3) 1) (progn (command "_pedit" "_M" ss3 "" "J" "0" "") ) (progn (command "_pedit" ss3 "") ) ) (princ) ) Best regards.1 point
-
1 - just reverse lst after making it, BUT number 2 - because you are not sorting the list at all, it just adds last inserted to beginning of lst (or end if you reverse), I edited the code a bit so its sorts by X axis from left to right, test it now if it works for you. I have a similar thing for my needs, but I added the block attribute number, so each block has a number and even if they are not in the same row (sorting from left to right), I sort pages by that number. But if this works for you no need for complicating it, just saying how it also can be done if you have layouts in multiple rows. (vl-load-com) (defun c:PDFA1 (/ dwg file hnd i len llpt lst mn mx ss tab urpt) (if (setq ss (ssget "_X" '((0 . "INSERT") (2 . "PDFA1")))) (progn (repeat (setq i (sslength ss)) (setq hnd (ssname ss (setq i (1- i))) tab (cdr (assoc 410 (entget hnd))) lst (cons (list hnd (cdr (assoc 10 (entget hnd))) tab) lst) ) ) (setq lst_sort (vl-sort lst '(lambda (x y) (< (car (cadr x)) (car (cadr y)))))) (setq i 0) (foreach x lst_sort (setq file (strcat (getvar 'DWGPREFIX) (substr (setq dwg (getvar 'DWGNAME)) 1 (- (strlen dwg) 4)) "-" (itoa (setq i (1+ i))) ".pdf" ) ) (if (findfile file) (vl-file-delete file) ) (vla-getboundingbox (vlax-ename->vla-object (car x)) 'mn 'mx) (setq llpt (vlax-safearray->list mn) urpt (vlax-safearray->list mx) len (distance llpt (list (car urpt) (cadr llpt))) ) (command "-plot" "yes" (car x) "DWG TO PDF.PC3" "ISO full bleed A1 (841.00 x 594.00 MM)" "Millimeters" "Landscape" "No" "Window" llpt urpt "Fit" "Center" "yes" "Standard-A1.ctb" "yes" "" ) (if (/= (caddr x) "Model") (command "No" "No" file "no" "Yes") (command file "no" "Yes" ) ) ) ) ) (princ) )1 point
-
I have plot titles in model but try not to use it. A better way is to make a rectang at the required scale using your A1 sheet, the A1 title block is saved in layouts at 1:1 scale then a mview is used to view the model at desired scale. It is a 2 step process make rectangs then make layouts so you can add more as you go along. This video is step 1, then just select all rectangs which are on a layer and make matching layouts. The code I have takes into account that you may have different orientation, Portrait or Landscape, even down to the rectang can be on an angle and Mview matches. Ok the sample dwg has been screwed with the 6000 is 4so 1st step is rescale back to match 6000 or 6.0 then make a retang at scale. Put title block in layout at 1:1 ie 841x594 - edges. Draw rectangs.mp4 I do charge a small fee as the code needs to be setup to match your title block. I am metric ignore scale in movie. Have a look at this dwg. Drawing1-2.dwg1 point