- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear community,
I use a LISP to get the coordinates of the polyline vertices, for further use in one command macro with DIESEL expression, for automating the entry of values for a special tool in AutoCAD Mechanical (AMAUTODIM). This tool will (almost) automatically create coordinate dimensions (Mechanical) on the four sides of the polyline, with a pre-set vertical and horizontal distance between the dimensions and the object.
Here the LISP:
(defun c:DimAutoOrdinateMECH ( / aadPPL)
(and
; polyline selection without object type test
(setq aadObj1 (car(entsel)))
; all vertices of the polyline
(setq aadPPL (mapcar 'cdr (vl-remove-if-not '(lambda(dp)(= (car dp) 10))(entget aadObj1))))
; vertices min. Y coordinate
(setq aad0V (car(vl-sort aadPPL (function (lambda(e1 e2)(<(cadr e1)(cadr e2)))))))
; vertices max. Y coordinate
(setq aadMV (car(vl-sort aadPPL (function (lambda(e1 e2)(>(cadr e1)(cadr e2)))))))
; vertices min. X coordinate
(setq aad0H (car(vl-sort aadPPL (function (lambda(e1 e2)(<(car e1)(car e2)))))))
; vertices max. X coordinate
(setq aadMH (car(vl-sort aadPPL (function (lambda(e1 e2)(>(car e1)(car e2)))))))
; insertion point vertically left
(setq aadPVL (mapcar '+ (car(vl-sort aadPPL (function (lambda(e1 e2)(<(car e1)(car e2)))))) '(-60 0 0)))
; insertion point horizontally top
(setq aadPHO (mapcar '+ (car(vl-sort aadPPL (function (lambda(e1 e2)(>(cadr e1)(cadr e2)))))) '(0 60 0)))
; insertion point vertically right
(setq aadPVR (mapcar '+ (car(vl-sort aadPPL (function (lambda(e1 e2)(>(car e1)(car e2)))))) '(60 0 0)))
; insertion point horizontally bottom
(setq aadPHU (mapcar '+ aad0V '(0 -60 0)))
)
)
One of the tasks of LISP is to find the points for the beginning of dimensions (the zero point). However, this LISP is only suitable for the following cases of object rotation (only one zero X- and Y-point):
In another case where object rotation allows for two zero X- and Y-points, this LISP defines naturally the same zero point for each dimensions:
My goal is to use the correct zero points for each side of the inserted coordinate dimension:
How to change the LISP to get these zero points combination?
Sorry for my expressions, I'm not a programmer 😎. Many thanks in advance for your help
+++ the only constant is the change +++ stay tuned for more +++
+++ since 03/2023 is Advance Steel in maintenance mode, no further development +++
Solved! Go to Solution.