aliscan Posted January 8, 2022 Posted January 8, 2022 Hi Can you help to add automatic numbering section to the following plugin? Thanks .................... (defun C:PRM ( / pl ent elist PL_Len ) (while (setq pl (entsel "\nSelecc. Entidad:")) (setq ent (car pl)) (setq elist (entget ent)) (command ".area" "O" ent) (setq PL_Len (getvar "perimeter")) (setq AR_Ent (getvar "Area")) (prompt "\n "); blank line feed ;(alert (strcat "\nLong.de Entidad = " (rtos PL_Len 2 2))), comentario ;(alert (strcat "\nArea.de Entidad = " (rtos AR_Ent 2 2))), comentario (setq pt1 (getpoint "\nDar Indicar pto Inic.para Inserc. de Resultado: ")) (setq pt2 (getpoint "\nDar Indicar pto Final para Inserc. de Resultado: ")) (setq LTT (strcat "Perim.=" (rtos PL_Len 2 2) "m.")) (setq AA (strcat "Área=" (rtos AR_Ent 2 2) "m2.")) (setq text_pantalla (strcat "\n" aa "\n" ltt)) (command "_mtext" pt1 pt2 text_pantalla "") (princ) ) ); cierre de funcion Quote
hosneyalaa Posted January 8, 2022 Posted January 8, 2022 Hi Have you attached an example drawing Quote
aliscan Posted January 8, 2022 Author Posted January 8, 2022 here is the file attached Drawing19.dwg Quote
hosneyalaa Posted January 8, 2022 Posted January 8, 2022 TRY (defun C:QQQQPRM ( / AA AR_ENT GION GIONXY LTT PL PL_LEN TEXT_PANTALLA) (while (setq pl (entsel "\nSelecc. Entidad:")) (PROGN (setq gion (vlax-invoke (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) 'addregion (list (vlax-ename->vla-object (car pl))))) (setq PL_Len (vlax-get (CAR gion ) 'perimeter)) (setq AR_Ent (vlax-get (CAR gion ) 'Area)) (setq gionXY (vlax-get (CAR gion ) 'CENTROID) ) (vla-delete (CAR gion )) (setq LTT (strcat "Perim.=" (rtos PL_Len 2 2) "m.")) (setq AA (strcat "?rea=" (rtos AR_Ent 2 2) "m2.")) (setq text_pantalla (strcat aa "\n" ltt)) (command "_mtext" gionXY gionXY text_pantalla "") ) (princ) ) ); cierre de funcion Quote
aliscan Posted January 8, 2022 Author Posted January 8, 2022 (edited) Mr. hosneyalaa: I want it to automatically number each room while typing the area and perimeter information. Sample: Room1 Area:.....m2 Length:....m. Room2 Area:.....m2 Length:....m. ... Thanks ....................Only numbering will be added to the plugin below.............. ********************** (defun C:PRM ( / pl ent elist PL_Len ) (while (setq pl (entsel "\nSelecc. Entidad:")) (setq ent (car pl)) (setq elist (entget ent)) (command ".area" "O" ent) (setq PL_Len (getvar "perimeter")) (setq AR_Ent (getvar "Area")) (prompt "\n "); blank line feed ;(alert (strcat "\nLong.de Entidad = " (rtos PL_Len 2 2))), comentario ;(alert (strcat "\nArea.de Entidad = " (rtos AR_Ent 2 2))), comentario (setq pt1 (getpoint "\nDar Indicar pto Inic.para Inserc. de Resultado: ")) (setq pt2 (getpoint "\nDar Indicar pto Final para Inserc. de Resultado: ")) (setq LTT (strcat "Perim.=" (rtos PL_Len 2 2) "m.")) (setq AA (strcat "Área=" (rtos AR_Ent 2 2) "m2.")) (setq text_pantalla (strcat "\n" aa "\n" ltt)) (command "_mtext" pt1 pt2 text_pantalla "") (princ) ) ); cierre de funcion Edited January 8, 2022 by aliscan Quote
aliscan Posted January 8, 2022 Author Posted January 8, 2022 It will be in the same code. So while writing the area and length, it will also write the automatic number. thanks Quote
hosneyalaa Posted January 8, 2022 Posted January 8, 2022 HI (defun C:QQQQPRM ( / AA AR_ENT GION GIONXY LTT PL PL_LEN TEXT_PANTALLA) (setq NO 0) (while (setq pl (entsel "\nSelecc. Entidad:")) (PROGN (setq gion (vlax-invoke (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) 'addregion (list (vlax-ename->vla-object (car pl))))) (setq PL_Len (vlax-get (CAR gion ) 'perimeter)) (setq AR_Ent (vlax-get (CAR gion ) 'Area)) (setq gionXY (vlax-get (CAR gion ) 'CENTROID) ) (vla-delete (CAR gion )) (setq LNO (strcat "NO.=" (rtos (setq NO (+ 1 NO ) ) 2 0))) (setq LTT (strcat "Perim.=" (rtos PL_Len 2 2) "m.")) (setq AA (strcat "?rea=" (rtos AR_Ent 2 2) "m2.")) (setq text_pantalla (strcat LNO "\n" aa "\n" ltt)) (command "_mtext" gionXY gionXY text_pantalla "") ) (princ) ) ); cierre de funcion 1 Quote
aliscan Posted January 8, 2022 Author Posted January 8, 2022 Mr. hosneyalaa: Is it possible for me to mark where the information will be written? That is, if it is written in the place I will mark, not in the center thanks Quote
aliscan Posted January 8, 2022 Author Posted January 8, 2022 If I exited the command it would be nice if it asked which number to start with. thanks Quote
aliscan Posted January 8, 2022 Author Posted January 8, 2022 If possible, create your own layer. Thanks Quote
mhupp Posted January 8, 2022 Posted January 8, 2022 (edited) Updated the code with all the changes you wanted. Make sure you are selecting closed polylines because the length/perimeter and area will be off otherwise. (defun C:foo (/ olay c ent PL_LEN AR_ENT LNO LTT AA TEXT_PANTALLA) (vl-load-com) (setvar 'cmdecho 0) (setq olay (getvar 'clayer)) ;save current layer name (command "_.Layer" "_M" "RoomInfo" "") ;create new layer for mtext to be added to (setq c (getint "\nNúmero de habitación: ")) ;ask for room number (while (setq ent (entsel (strcat "\nseleccionar habitación " (itoa c) ":"))) ;ask user to select room polyline (setq ent (vlax-ename->vla-object (car ent)) PL_LEN (vlax-get ent 'Length) ;get length of polyline = perimeter AR_ENT (vlax-get ent 'Area) ;get area of polyline LNO (strcat "Room:" (itoa c)) ;set text room number LTT (strcat "Perim=" (rtos PL_Len 2 2) "m") ;set perimeter of room AA (strcat "?rea=" (rtos AR_Ent 2 2) "m2") ;set area of room TEXT_PANTALLA (strcat LNO "\n" AA "\n" LTT) ;joing it all togther for mtext c (1+ c) ;step up to next room number ) (command "_.Mtext" pause "" TEXT_PANTALLA "") ;creat mtext where user clicks ) (setvar 'clayer olay) (setvar 'cmdecho 1) (princ) ) Edited January 10, 2022 by mhupp added notes Quote
aliscan Posted January 10, 2022 Author Posted January 10, 2022 hello mhupp I could not understand the working logic of this code. What I want is to add numbering to the code I shared Thanks Quote
mhupp Posted January 10, 2022 Posted January 10, 2022 7 hours ago, aliscan said: hello mhupp I could not understand the working logic of this code. What I want is to add numbering to the code I shared Thanks Your code doesn't have anything referring to a room number. what you have circled is either generated by another command or by hand. I edited your lisp to do what you asked. added notes so you can see what each step does. Quote
BIGAL Posted January 11, 2022 Posted January 11, 2022 My $0.05 replace this (command "_.Mtext" pause "" TEXT_PANTALLA "") with insert a block with 3 attributes. Each time you start code can check the block and get last number. Or can keep mtext on 1 layer only, and again read 1st line get last number. Quote
Recommended Posts
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.