LISP for auto dimension the shortest distance between two polygons (one inside another one)

LISP for auto dimension the shortest distance between two polygons (one inside another one)

elena_spaseska
Explorer Explorer
483 Views
7 Replies
Message 1 of 8

LISP for auto dimension the shortest distance between two polygons (one inside another one)

elena_spaseska
Explorer
Explorer

Hello,

I work on urban plans and I need to show the shortest distance between the object(building) and the parcel. Since the urban plans have a big amount of parcels I need help creating a lisp for auto dimension (aligned) between to polygons (closed polylines) one inside another. 

I would be really grateful if someone helps me with creating a code for a lisp, for this problem.

The example file in attachment.

@hak_vz  maybe you can help me.

0 Likes
484 Views
7 Replies
Replies (7)
Message 2 of 8

Sea-Haven
Mentor
Mentor

Try this, as your example has like 1 2 3 or more dims, no simple do all, but this is reasonably fast once you get use to it.

 

 

; Lot dim by AlanH Nov 2024

(defun c:lotdim ( / ent obj pt1 pt2 oldsnap)
  (setq oldsnap (getvar 'osmode))
  (while (setq ent (car (entsel "\nPick bounding object Enter to stop ")))
   (setq obj (vlax-ename->vla-object ent))
   (setvar 'osmode 1)
   (while (setq pt1 (getpoint "\nPick point on building Enter to stop "))
    (setq pt2 (vlax-curve-getClosestPointTo obj pt1))
    (command "dimaligned" "_non" pt1 "_non" pt2 "_non" pt2)
   )
  (setvar 'osmode oldsnap)
  )
  (princ)
)
(c:lotdim)

 

SeaHaven_0-1731887400170.png

 

0 Likes
Message 3 of 8

calderg1000
Mentor
Mentor

Regards @elena_spaseska 

Try this code, Size the minimum distance. Set the measurement style for your presentation

 

 

;;;___
(defun c:dp (/ s b lp k ld d lpm m n)
  (setq s  (car (entsel "\nSelect interior polygon: "))
        b  (vlax-ename->vla-object (car (entsel "\nSelect the Parcel: ")))
        lp (mapcar 'cdr (vl-remove-if-not '(lambda (j) (= (car j) 10)) (entget s)))
  )
  (foreach k lp
    (setq p (vlax-curve-getclosestpointto b k))
    (setq ld (append ld (list (cons (distance p k) (list p k)))))
  )
  (setq lo (vl-sort ld '(lambda (l m) (< (car l) (car m))))
        d  (caar lo)
        lpm (cdar lo)
  )
  (command "_dimaligned" "_non" (car lpm) "_non" (cadr lpm) (cadr lpm))
  (princ (strcat "Dmin= " (rtos d 2 2)))
  (princ)
)

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 4 of 8

elena_spaseska
Explorer
Explorer

This could work but I need in the osnap mode the endpoint, midpoint, intersection, extension, nearest and apparent intersection to be on, this turn lsp turns off. I dimension with extension of the line of the building and needs to be aligned. I need the shortest distance of the each side of the building to the parcel. Screenshot 2024-11-18 114425.jpg

0 Likes
Message 5 of 8

elena_spaseska
Explorer
Explorer
Thank you, but this didnt work for me.
0 Likes
Message 6 of 8

Kent1Cooper
Consultant
Consultant

I'm not sure I have a good idea of how that could be done, but first:  You're going to need to spell out more criteria.  In this, the white Dimensions are the ones in your drawing.  Why do you have one such Dimension for some buildings, two for some, three for others, etc.?

Kent1Cooper_0-1731929283767.png

I added the red ones.  Should they not be included?  If not, what determines in which directions a building is dimensioned, and in which directions it is not?

The yellow ones are "false" Dimensions of yours, that don't give the distance of the building from the closest property line.  I added the magenta ones, which surely are what they would want to see.  If the yellow ones are really correct, what determines when one like that should be drawn, and in which of the possible directions?

Etc.

Kent Cooper, AIA
0 Likes
Message 7 of 8

elena_spaseska
Explorer
Explorer

Yes you are right, the yellow ones are incorrect, the right ones are magenta ones. The dimension needs to be from all 4 sides of the building, but I have also buildings in separate parcels but next to each other (picture attached). I don't know if its possible to create a lsp for this kind of dimensioning, because the parcels are different. 

elena_spaseska_1-1731931595838.png

 

 

0 Likes
Message 8 of 8

Sea-Haven
Mentor
Mentor

 I don't think you can have a full auto solution the shapes are to random, you can do every vertice automatically but that would be a overkill. 

 

Realigning the dim could be done. Need to think about it. Drawing the dim in the direction of gap is the correct answer.

0 Likes