Lisp automatic dimension

Lisp automatic dimension

Anonymous
Not applicable
4,358 Views
5 Replies
Message 1 of 6

Lisp automatic dimension

Anonymous
Not applicable

Pls help me Lisp Automatic Dimension

Images depicting what to do

Dim from Red line to Blue line with angle = 90 degrees

 

Untitled.jpg

0 Likes
4,359 Views
5 Replies
Replies (5)
Message 2 of 6

Moshe-A
Mentor
Mentor

@Anonymous  hi,

 

can you tell us more what we see here?

is this a manual drawing or do you have some automation?

 

moshe

 

Message 3 of 6

ВeekeeCZ
Consultant
Consultant

Welcome to these Forums!

I guess you came here to get help on how to code your own programs. Is it that right?

The following code supposed to show you what's possible.  Consider that as a welcome gift because I feel like generous today. Don't hesitate to ask if you have any question about the code.

 

(vl-load-com)

(defun c:DimToPolyline ( / i p1 p2 px ints obj pl pts ss tmp used pair)
  
  (if (and (setq ss (ssget '((0 . "LINE"))))
           (setq pl (car (entsel "\nSelect polyline: ")))
           (or (= "LWPOLYLINE" (cdr (assoc 0 (entget pl))))
               (prompt "\nError: Selected object is not a polyline!"))
           (setq obj (vlax-ename->vla-object pl))
           (setq pts (mapcar '(lambda (x) (list (cdr (assoc 10 x))
                                                (cdr (assoc 11 x))))
                             (mapcar 'entget (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))))
           )
    (foreach pair pts
      (foreach i '(0 1)
        (and (setq p1 (nth i pair)
                   p2 (nth (- 1 i) pair))
             (setq tmp (entmakex (list '(0 . "LINE") (cons 10 p1) (cons 11 (polar p1 (+ (angle p1 p2) (/ pi 2)) 1.)))))
             (setq ints (LM:intersections obj (vlax-ename->vla-object tmp) acextendotherentity))
             (setq ints (vl-sort ints (function (lambda (e1 e2)
                                                  (< (distance e1 p1)
                                                     (distance e2 p1))))))
             (setq px (car ints))
             (or (and (LM:UniqueFuzz-p (cons (append p1 px) used) 0.01)
                      (setq used (cons (append p1 px) used))
                      (vl-cmdf "_.dimaligned" "_non" p1 "_non" (car ints) "_non" "@")
                      )
                 T)
             (entdel tmp)))))
  (princ)
  )



;; Intersections  -  Lee Mac
;; Returns a list of all points of intersection between two objects
;; for the given intersection mode.
;; ob1,ob2 - [vla] VLA-Objects
;;     mod - [int] acextendoption enum of intersectwith method

(defun LM:intersections ( ob1 ob2 mod / lst rtn )
  (if (and (vlax-method-applicable-p ob1 'intersectwith)
           (vlax-method-applicable-p ob2 'intersectwith)
           (setq lst (vlax-invoke ob1 'intersectwith ob2 mod))
           )
    (repeat (/ (length lst) 3)
      (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn)
            lst (cdddr lst)
            )
      )
    )
  (reverse rtn)
  )

;; Unique-p with Fuzz  -  Lee Mac
;; Returns T if a list contains items considered distinct to
;; a given tolerance

(defun LM:UniqueFuzz-p ( l f )
  (or (null l)
      (and (not (vl-some (function (lambda ( x ) (equal x (car l) f))) (cdr l)))
           (LM:UniqueFuzz-p (cdr l) f)
           )
      )
  )
Message 4 of 6

Anonymous
Not applicable

Hi @Moshe-A,

Thanks for your reply.

 

Yes, we are developing to automate some continuous repetition work to reduce working time, as well as automate manipulation.

First I draw a Pline, use "test" lisp to create the cells and use "Break" lisp to break the line, then select a red line representing Dim to the blue line.

I did it automatically by lisp (lisp attach)

 

0 Likes
Message 5 of 6

Anonymous
Not applicable

Hi @ВeekeeCZ 

 

I'm programming code about HTML, SQL. I have no experience with CAD code and CAD commands, I have reviewed the documents in the past 1 month but have no results. I think it is a series of automated CAD commands that are executed. But I still can't find it.
Thank for your gift. This is amazing.

I made drawings with attached lisp.

Regarding your code, I applied it to the drawing, the top part was amazing (image 1), the horizontal part was incorrect (image 2), it was 49

Picture 1Picture 1Picture 2Picture 2

 

 

 

0 Likes
Message 6 of 6

Anonymous
Not applicable

@ВeekeeCZ 

Pls help me again

0 Likes