BIGAL Posted June 3, 2021 Posted June 3, 2021 Just a suggestion when posting code use the Code icon it will put it in a box for you, welcome aboard. Quote
tanis17337 Posted November 30, 2022 Posted November 30, 2022 On 6/3/2021 at 4:38 PM, minejash said: Try this one, It gives all selected polyline dimensions.. You can select similar the Pline and delete it later. DIMENSION POLY.LSP 2.96 kB · 24 downloads AFTER LOADED THIS LISP THEN WHAT COMMAND? Quote
Steven P Posted November 30, 2022 Posted November 30, 2022 (edited) pdim (if you look through the files you will find somethng like (defun c:pdim ( / ) at the start of each routine. If there is a 'c:' whatever follows (here pdim) is the command to use). Edited November 30, 2022 by Steven P Quote
BIGAL Posted December 1, 2022 Posted December 1, 2022 I have not done it for a while but should get back in the habit of when loading code add a little message at the end about how to run. I find "alert" is good but keep it outside the defun so it only displays once. (defun c:mycode ( / a s d f ) .......... ) (alert "to run just type MYCODE") or (defun c:mycode ( / a s d f ) .......... ) (c:mycode) 1 Quote
Momi Posted December 17, 2023 Posted December 17, 2023 (edited) @Isaac26a is there any way "LP2T" to select multiple objects at once and put the length in middle of square/circle ? ;;;;;;;;;;;; Program lp2t selects a pline and puts its length in to a new text. ;;;;;;;;;;;; ;;;;;;;;;;;; by Isaac A. 20210603 ;;;;;;;;;;;; https://www.cadtutor.net/forum/topic/73155-polyline-lengths/?_fromLogin=1 ;********** Program to obtain the length of a pline and put it into a text ********** (vl-load-com) (defun C:lp2t (/ long poli) (setvar "cmdecho" 0) (vl-cmdf "_.undo" "_begin") (setq oldosm (getvar "osmode")) (setvar "osmode" 0) (setq poli (car (entsel "\nSelect the polyline"))) (setq long 0) (vl-cmdf "_.area" "_e" poli) (setq long (getvar "perimeter")) (setq pt11 (getpoint "Pick a point to insert the text")) (vl-cmdf "_.style" "times" "times new roman" "0" "1" "" "" "" "_.text" "_s" "times" pt11 "1" "0" (strcat "L=" (rtos long 2 2) "m.")) (vl-cmdf "_.undo" "_end") (setvar "osmode" oldosm) (princ "\n") (princ) ) ;;; Ends c:lp2t Edited June 28 by SLW210 Added Code Tags! Quote
BIGAL Posted December 17, 2023 Posted December 17, 2023 Using VL makes getting the length and area much easier, you do though need to look at what type of object you have picked. (defun c:wow ( / ss x len pt) (vl-cmdf "_.style" "times" "times new roman" "0" "1" "" "" "") (setq ss (ssget '((0 . "Lwpolyline,Circle")))) (if (= ss nil) (alert "No plines or circles selected ") (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (if (= (vlax-get obj 'Objectname) "AcDbPolyline") (progn (setq len (rtos (vlax-get obj 'Length) 2 3)) (setq Pt (osnap (vlax-curve-getStartPoint obj) "gcen")) ) (progn (setq len (rtos (vlax-get obj 'Circumference) 2 2)) (setq pt (vlax-get obj 'center)) ) ) (vl-cmdf "_.text" "_s" "times" pt "1" "0" (strcat "L=" len "m.")) ) ) (princ) ) (c:wow) Quote
MDC Posted June 28 Posted June 28 On 6/3/2021 at 1:09 PM, Tharwat said: Just for fun. If your current text style with zero height then the program would get the width factor as the text height instead. (defun c:Test (/ old new len ins sty str get grd) ;; Tharwat - 3.Jun.2021 ;; (setq old (entlast)) (vl-cmdf "_.Pline") (while (< 0 (getvar 'CMDACTIVE)) (vl-cmdf "\\") ) (and (not (equal old (setq new (entlast)))) (setq len (vlax-curve-getdistatparam new (vlax-curve-getendparam new)) ) (entdel new) (setq ins (trans (cadr (grread 13 0)) 1 0) sty (getvar 'TEXTSTYLE) str (entmakex (list '(0 . "TEXT") (cons 10 ins) (cons 11 ins) (cons 40 (cdr (assoc (if (zerop (cdr (assoc 40 (setq get (entget (tblobjname "STYLE" sty))) ) ) ) 41 40 ) get ) ) ) (cons 1 (rtos len 2 2)) (cons 7 sty) ) ) get (entget str) ) (while (= (car (setq grd (grread t 15 0))) 5) (entmod (subst (cons 10 (cadr grd)) (assoc 10 get) get)) ) ) (princ) ) How would you modify this to leave the polyline and not delete it? TiA Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.