Jump to content

Recommended Posts

Posted

Hi, anyone know of a Lisp that can auto-create dimensions? I've tweaked the dimension properties and want to use a Lisp to make new ones based on those settings, plus rename them.

Posted

@pondpepo9

I can't tell you if what you are looking for exists unless you can be more specific on what you want. Ideally, post a DWG with the Before and After and explain in more detail what the workflow should be. Then if someone has something they are willing to share, write, or alter - we can let you know.

 

PLEASE NOTE: This is not a forum just to order up free programs. We prefer helping those who wish to learn programming and need a place to start, which is the purpose of this forum.

  • Like 3
Posted
  On 1/23/2025 at 2:49 PM, pkenewell said:

@pondpepo9

I can't tell you if what you are looking for exists unless you can be more specific on what you want. Ideally, post a DWG with the Before and After and explain in more detail what the workflow should be. Then if someone has something they are willing to share, write, or alter - we can let you know.

 

PLEASE NOTE: This is not a forum just to order up free programs. We prefer helping those who wish to learn programming and need a place to start, which is the purpose of this forum.

Understood. Thank you! 😊

Posted

Are you using AutoCAD LT 2024 as indicated?

Posted

Hi,

I have this that could be used as an example for creating a dimension style.
I hope this inspires you to create your own dimension style.

(defun c:DimPline ( / adoc space obj_dim obj_angdim height_dim pl ent obj dxf_ent last_pt pr_pt lst_pt nw_obj)
	(vl-load-com)
	(setq
		adoc (vla-get-activedocument (vlax-get-acad-object))
		space
		(if (= 1 (getvar "CVPORT"))
			(vla-get-paperspace adoc)
			(vla-get-modelspace adoc)
		)
		obj_dim (vla-add (vla-get-Dimstyles adoc) "DIMPLINE")
		obj_angdim (vla-add (vla-get-Dimstyles adoc) "DIMANGPLINE")
	)
	(vla-put-activedimstyle adoc obj_dim)
	(initget 6)
	(setq height_dim (getdist (getvar "VIEWCTR") (strcat "\nHeight of dimension text <" (rtos (getvar "DIMTXT")) ">: ")))
	(if height_dim (vla-setvariable adoc "DIMTXT" height_dim) (setq height_dim (getvar "DIMTXT")))
	(mapcar '(lambda (data_list / ) (vla-setvariable adoc (car data_list) (cdr data_list)))
		(list
			(cons "DIMPOST" "")
			(cons "DIMAPOST" "")
			(cons "DIMSCALE" 1.0)
			(cons "DIMASZ" (getvar "DIMTXT"))
			(cons "DIMEXO" (* 0.625 (getvar "DIMTXT")))
			(cons "DIMDLI" (* 3.75 (getvar "DIMTXT")))
			(cons "DIMEXE" (* 1.25 (getvar "DIMTXT")))
			(cons "DIMRND" 0.0)
			(cons "DIMDLE" 0.0)
			(cons "DIMTP" 0.0)
			(cons "DIMTM" 0.0)
			(cons "DIMFXL" (* 10.0 (getvar "DIMTXT")))
			(cons "DIMFXLON" 1)
			(cons "DIMATFIT" 3)
			(cons "DIMTIX" 1)
			(cons "DIMCEN" (* 2.5 (getvar "DIMTXT")))
			(cons "DIMTSZ" 0.0)
			(cons "DIMALTF" 0.0394)
			(cons "DIMLFAC" 1.0)
			(cons "DIMTVP" 0.0)
			(cons "DIMTFAC" 1.0)
			(cons "DIMGAP" (* 0.625 (getvar "DIMTXT")))
			(cons "DIMALTRND" 0.0)
			(cons "DIMTOL" 0)
			(cons "DIMLIM" 0)
			(cons "DIMTIH" 0)
			(cons "DIMTOH" 0)
			(cons "DIMSE1" 0)
			(cons "DIMSE2" 0)
			(cons "DIMTAD" 1)
			(cons "DIMZIN" 0)
			(cons "DIMALT" 0)
			(cons "DIMALTD" 3)
			(cons "DIMTOFL" 1)
			(cons "DIMSAH" 0)
			(cons "DIMTIX" 0)
			(cons "DIMSOXD" 0)
			(cons "DIMCLRD" 0)
			(cons "DIMCLRE" 0)
			(cons "DIMCLRT" 0)
			(cons "DIMADEC" 2)
			(cons "DIMDEC" 2)
			(cons "DIMTDEC" 2)
			(cons "DIMALTU" 2)
			(cons "DIMALTTD" 3)
			(cons "DIMAUNIT" 0)
			(cons "DIMFRAC" 0)
			(cons "DIMLUNIT" 2)
			(cons "DIMDSEP" ".")
			(cons "DIMTMOVE" 0)
			(cons "DIMJUST" 0)
			(cons "DIMSD1" 0)
			(cons "DIMSD2" 0)
			(cons "DIMTOLJ" 0)
			(cons "DIMTZIN" 0)
			(cons "DIMALTZ" 0)
			(cons "DIMALTTZ" 0)
			(cons "DIMUPT" 0)
			(cons "DIMBLK" "_OBLIQUE")
			(cons "DIMBLK2" "_OBLIQUE")
		)
	)
	(vla-copyfrom obj_dim adoc)
	(vla-copyfrom obj_angdim adoc)
	(princ "\nSelect polylines: ")
	(while (null (setq pl (ssget '((0 . "LWPOLYLINE"))))))
	(repeat (setq n (sslength pl))
		(setq
			ent (ssname pl (setq n (1- n)))
			obj (vlax-ename->vla-object ent)
			dxf_ent (entget ent)
			lst_pt (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) dxf_ent))
		)
		(if (not (zerop (logand 1 (cdr (assoc 70 dxf_ent)))))
			(setq last_pt (car lst_pt) lst_pt (cons (last lst_pt) lst_pt) pr_pt (last lst_pt))
			(setq pr_pt nil)
		)
		(while (cdr lst_pt)
			(vla-put-activedimstyle adoc obj_dim)
			(setq nw_obj
				(vla-addDimAligned
					space
					(vlax-3d-point (car lst_pt))
					(vlax-3d-point (cadr lst_pt))
					(vlax-3d-point (mapcar '(lambda (a b) (* (+ a b) 0.5)) (car lst_pt) (cadr lst_pt)))
				)
			)
			(vlax-put nw_obj 'TextPosition (polar (vlax-get nw_obj 'TextPosition) (+ (angle (car lst_pt) (cadr lst_pt)) (* 0.5 pi)) (* 3.25 (getvar "DIMTXT"))))
			(if pr_pt
				(progn
					(vla-put-activedimstyle adoc obj_angdim)
					(setq nw_obj
						(vla-AddDimAngular
							space
							(vlax-3d-point (car lst_pt))
							(vlax-3d-point (polar (car lst_pt) (angle pr_pt (car lst_pt)) (distance pr_pt (car lst_pt))))
							(vlax-3d-point (cadr lst_pt))
							(vlax-3d-point
								(polar
									(car lst_pt)
									(+
										(angle pr_pt (car lst_pt))
										(* 0.5 (- (angle (car lst_pt) (cadr lst_pt)) (angle pr_pt (cadr lst_pt))))
									)
									(* 5.0 (getvar "DIMTXT"))
								)
							)
						)
						pr_pt (car lst_pt)
					)
				)
				(setq pr_pt (car lst_pt))
			)
			(setq lst_pt (cdr lst_pt))
		)
		(if (cdr lst_pt)
			(setq nw_obj
				(vla-AddDimAngular
					space
					(vlax-3d-point (car lst_pt))
					(vlax-3d-point (polar (car lst_pt) (angle pr_pt (car lst_pt)) (distance pr_pt (car lst_pt))))
					(vlax-3d-point (cadr lst_pt))
					(vlax-3d-point
						(polar
							(car lst_pt)
							(+
								(angle pr_pt (car lst_pt))
								(* 0.5 (- (angle (car lst_pt) (cadr lst_pt)) (angle pr_pt (car lst_pt))))
							)
							(* 5.0 (getvar "DIMTXT"))
						)
					)
				)
			)
		)
	)
	(princ)
)

 

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...