Jump to content

Leaderboard

Popular Content

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

  1. Hello everybody! I made some modification to a lisp of @Tharwat found on this forum (thank you Tharwat!). The modifications I made are: to add a number before each pair of coordinates (starting with a chosen number) and also to save the file automatically near the DWG with some suffix (not to open a "save as" window). I would be grateful if anybody could help me with some new modifications: 1. To add 2 new lines at the end of the txt file: polyline area and polyline perimeter. 2. To add a column with the distance between the points So now the output is 1,Y,X 2,Y,X ... n,Y,X And I would like it to be: 1,Y,X,32.76 *distance between 1 and 2 2,Y,X,35.89 *distance between 2 and 3 ... n,Y,X,50.65 *distance between n and 1 Area=500 Perimeter=200 Numbers are random. DWG should be saved for the lisp to work. I am using ProgeCAD so some functions may not work (though 90% do) so the simplest solution (with the most basic functions) would be best. Thank you in advance! exppl.lsp
    1 point
  2. Have you tried my post... It should allow multiple polylines selection... Only lack is that it's not applicable for arced segmented polylines... Tschus... M.R.
    1 point
  3. Something like this ? (defun c:exppl (/ ss fl op) ;;----------------------------------------------------;; ;; Author : Tharwat Al Choufi ;; ;; website: https://autolispprograms.wordpress.com ;; ;;----------------------------------------------------;; (initget 6) (or (setq nr (getint "\nNumber of first point <1>:")) (setq nr 1) ) (princ "\nSelect polyline:") (and (setq ss (ssget ":S" '((0 . "LWPOLYLINE,POLYLINE")))) (setq fl (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4) ) ) (setq op (open (strcat (getvar "dwgprefix") fl "_exppl.txt") "w")) (progn ((lambda (i / sn p d) (while (setq sn (ssname ss (setq i (1+ i)))) (mapcar '(lambda (x) (and (= (car x) 10) (or (and p (setq d (distance p (setq p (cdr x))))) (setq p (cdr x)) ) (write-line (strcat (itoa nr) "," (rtos (cadr p) 2 3) "," (rtos (car p) 2 3) (if d (strcat "," (rtos d 2 3)) "" ) ) op ) (setq nr (1+ nr)) ) ) (entget sn) ) (foreach itm (list (list "Perimeter = " (vlax-curve-getdistatparam sn (vlax-curve-getendparam sn) ) ) (list "Area = " (vlax-curve-getarea sn)) ) (write-line (strcat (car itm) (rtos (cadr itm) 2 3)) op) ) ) ) -1 ) (close op) ) ) (princ) )
    1 point
  4. if talking a dynamic block then yes thanks to Lee-mac 1st, then can display visibility values and choose. Works for any dynamic block as it reads the visibility values. You insert block and then visibility values are displayed. Is this what you want as its 3 lisps, 2 are library functions the dcl and Lee-mac dynamic block functions. let me know will post code.
    1 point
  5. Lee Mac has a fairly comprehensive set of routines here ( http://www.lee-mac.com/dynamicblockfunctions.html#getvisibilityparametername ) and to use (entlast) I think you'll need to change that to be a VLA-Object something like: (setq blk (vlax-ename->vla-object (entlast))) He is usually pretty good with his routines and fairly easy to follow
    1 point
  6. No worries @RonnieBN , please find the latest version that should cover the two options with / without ID [ Yes , No ] < Default value Tes > as ordered in the program. Please try the following untested codes and let me know how you get on with it. (defun c:Test (/ *error* rep int sel zom cad ent lst ref one two out csv get) ;; Tharwat Al Choufi - Date: 8.Mar.2021 ;; (defun *error* (msg) (and cad zom (vla-zoomprevious cad)) (and msg (not (wcmatch (strcase msg) "*CANCEL*,*EXIT*,*BREAK*")) (princ (strcat "\nError =>: " msg)) ) (princ) ) ;; ;; (and (or (initget 6 "Yes No") (setq rep (cond ((getkword "\nInclude ID column [Yes,No] < Yes > : ")) ("Yes") ) ) ) (princ "\nSelect closed polylines with four corners : ") (setq int -1 sel (ssget '((0 . "*POLYLINE") (-4 . "<AND") (-4 . "&=") (70 . 1) (90 . 4) (-4 . "AND>") ) ) ) (setq zom (or (vla-zoomextents (setq cad (vlax-get-acad-object))) t) ) (while (setq int (1+ int) ent (ssname sel int) ) (setq lst nil) (foreach p (entget ent) (if (= (car p) 10) (setq lst (cons (cdr p) lst)) ) ) (and (setq one (distance (car lst) (cadr lst)) two (distance (car lst) (last lst)) ) (if (equal (cadar lst) (cadadr lst) 1e-4) (setq len one wid two ) (setq len two wid one ) ) (setq out (cons (list len wid (if (and (= rep "Yes") (setq ref (ssget "_CP" lst '((0 . "TEXT")))) ) (cdr (assoc 1 (entget (ssname ref 0)))) "," ) ) out ) ) ) ) (or (setq zom (vla-zoomprevious cad)) t) (setq csv (getfiled "Specify file name" (getvar 'DWGPREFIX) "csv" 1) ) (setq get (open csv "w")) (write-line (strcat "L,W" (if (= rep "Yes") ",ID" "" ) ) get ) (foreach itm out (write-line (strcat (rtos (car itm) 2 2) "," (rtos (cadr itm) 2 2) "," (caddr itm) ) get ) ) (close get) ) (princ) ) (vl-load-com)
    1 point
×
×
  • Create New...