Jump to content

Recommended Posts

Posted

can anyone help pls. I want cad lsp make 2 linear dim inside the rectangle or room (only 2 dimension at fixed distance 0.5 from top side & left side from it) and lable the room from any numbring option , table option or Radio buttons. thanks to forum .

dim room and labele.dwg

Posted

Try This,

(defun c:dimauto (/ ss   ent dxf_ent   var_cmdecho var_osmode llpt urpt)
    (defun *error* ( msg )
        (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
            (princ (strcat "\nError: " msg))
        )
    (setvar 'cmdecho var_cmdecho)
    (setvar 'osmode var_osmode)
        (princ)
    )

  (setq var_cmdecho (getvar "cmdecho"))
  (setq var_osmode (getvar "osmode"))
  (setvar 'cmdecho 0)
  (setvar 'osmode 0)
  (or sn (setq sn 1))
(initget 4)
(if (setq tmp1 (getint  (strcat "\nEnter Starting Number :  <" (rtos sn 2 0) ">: ")))
    (setq sn  tmp1)
)


(while (setq ss (ssget ":S" (list '(0 . "*POLYLINE")   )))
	(if ss	(repeat 
				(setq n (sslength ss))
				(setq
					ent (ssname ss (setq n (1- n)))
					dxf_ent (entget ent)
				)
				(vla-getboundingbox (vlax-ename->vla-object ent) 'mn 'mx)
				(setq llpt (vlax-safearray->list mn))
				(setq urpt (vlax-safearray->list mx))
				(setq midpt (mapcar '(lambda (x y) (/ (+ x y) 2)) llpt urpt))
				(command "_.DIMALIGNED" (list (car llpt) (cadr urpt)) urpt (list (car llpt) (- (cadr urpt) 0.5)))
				(command "_.DIMALIGNED" (list (car llpt) (cadr urpt)) llpt (list (+ (car llpt) 0.5) (cadr urpt)))
				(make_text (list (car midpt) (- (cadr midpt) 0.5)) (rtos  sn 2 0))
				(setq sn (1+ sn))
			)
			)
)
    (setvar 'cmdecho var_cmdecho)
    (setvar 'osmode var_osmode)
(princ)
);defun

(defun make_text  (txt_pt txt_val)
 (entmake (list '(0 . "TEXT")
                '(8 . "0")
                (cons 10 txt_pt)
                (cons 40 0.2895)
                (cons 1 txt_val)
                '(50 . 0.0)
                '(71 . 0)
                '(72 . 1)
                '(73 . 2)
                (cons 11 txt_pt))))


(princ "\nDIMAUTO" )
(princ)

 

DimAuto.lsp

  • Like 1
Posted

thanks for help, its work for dim the room , but not for label room like living room...the autocad request for Enter Starting Number :  <1>: , if it possible i want choose number or label from list or command line . when i pick it then the label room insert automatically at the middle of the room .. and thanks again for help ..

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