Jump to content

lisp needed


rodi

Recommended Posts

I need a lisp to convert lines or polylines to dimensions. Dim command actually does this by selecting object but i want to select multiple lines or plines at once and turn them into dimensions without leaving any lines behind. Can somebody help me with a lisp routine please?

Link to comment
Share on other sites

(defun c:AD (/ *error* v l ss i)
 ;;     Tharwat 06. August. 2014        ;;
 (defun *error* (u)
   (if v
     (mapcar 'setvar '(CMDECHO OSMODE) v)
   )
   (if (wcmatch (strcase u) "*BREAK*,*CANCEL*,*EXIT*")
     (princ (strcat "\n ** Error : " msg " **"))
   )
 )
 (setq v (mapcar 'getvar '(CMDECHO OSMODE)))
 (princ "\n Select POLYLINES only ...")
 (if (setq ss (ssget '((0 . "LWPOLYLINE") (90 . 2))))
   (progn
     (mapcar 'setvar '(CMDECHO OSMODE) '(0 0))
     (repeat (setq i (sslength ss))
       (setq l (mapcar 'cdr
                       (vl-remove-if-not
                         (function (lambda (p) (eq (car p) 10)))
                         (entget (ssname ss (setq i (1- i))))
                       )
               )
       )
       (command
         "._dimaligned"
         (car l)
         (cadr l)
         (polar (car l) (+ (* pi 0.5) (angle (car l) (cadr l))) 0.)
       )
     )
   )
 )
 (*error* nil)
 (princ)
)
(vl-load-com)

Edited by SLW210
Code Tags
Link to comment
Share on other sites

(defun c:AD (/ *error* v l ss i)
 ;;     Tharwat 06. August. 2014        ;;
 (defun *error* (u)
   (if v
     (mapcar 'setvar '(CMDECHO OSMODE) v)
   )
   (if (wcmatch (strcase u) "*BREAK*,*CANCEL*,*EXIT*")
     (princ (strcat "\n ** Error : " msg " **"))
   )
 )
 (setq v (mapcar 'getvar '(CMDECHO OSMODE)))
 (princ "\nölçüsünü istediğin polyline ları seç")
 (if (setq ss (ssget '((0 . "LWPOLYLINE") (90 . 2))))
   (progn
     (mapcar 'setvar '(CMDECHO OSMODE) '(0 0))
     (repeat (setq i (sslength ss))
       (setq l (mapcar 'cdr
                       (vl-remove-if-not
                         (function (lambda (p) (eq (car p) 10)))
                         (entget (ssname ss (setq i (1- i))))
                       )
               )
       )
       (command
         "._dimaligned"
         (car l)
         (cadr l)
         (polar (car l) (+ (* pi 0.5) (angle (car l) (cadr l))) 0.)
       )
     )
   )
 )
 (*error* nil)
 (princ)
)
(vl-load-com)

Link to comment
Share on other sites

nope :( that didnt work.

 

probably you have to remove the (90 . 2) aswel so :

 

 (setq ss (ssget '((0 . "LWPOLYLINE,LINE")))) 

 

but I must admit that I have not tried Tharwats code , just looked at the ssget part (far to hot for coding pfff)

 

gr. Rlx

Link to comment
Share on other sites

probably you have to remove the (90 . 2) aswel so :

 

 (setq ss (ssget '((0 . "LWPOLYLINE,LINE")))) 

 

but I must admit that I have not tried Tharwats code , just looked at the ssget part (far to hot for coding pfff)

 

gr. Rlx

 

thx but didn't work.

Link to comment
Share on other sites

I need a lisp to convert lines or polylines to dimensions. Dim command actually does this by selecting object but i want to select multiple lines or plines at once and turn them into dimensions without leaving any lines behind. Can somebody help me with a lisp routine please?

 

Here you go:

(defun c:ad (/ *error* v l ss i)
 (vl-load-com)
 ;; Tharwat 06. August. 2014 ;;
 ;; RJP modified to include lines - 6.20.2017
 (defun *error* (u)
   (and v (mapcar 'setvar '(cmdecho osmode) v))
   (and u
 (wcmatch (strcase u) "*BREAK*,*CANCEL*,*EXIT*")
 (princ (strcat "\n ** Error : " msg " **"))
   )
 )
 (if (setq ss (ssget (list '(-4 . "<OR") '(-4 . "<AND") '(0 . "LWPOLYLINE") '(90 . 2)
		    '(-4 . "AND>") '(0 . "LINE") '(-4 . "OR>")
		   )
       )
     )
   (progn (setq v (mapcar 'getvar '(cmdecho osmode)))
   (mapcar 'setvar '(cmdecho osmode) '(0 0))
   (repeat (setq i (sslength ss))
     (setq l (mapcar 'cdr
		     (vl-remove-if-not
		       (function (lambda (p) (member (car p) '(10 11))))
		       (entget (ssname ss (setq i (1- i))))
		     )
	     )
     )
     (command "._dimaligned"
	      (car l)
	      (cadr l)
	      (polar (car l) (+ (* pi 0.5) (angle (car l) (cadr l))) 0.)
     )
   )
   )
 )
 (princ)
)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...