Jump to content

Recommended Posts

Posted

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

num.jpg

Posted

Hi
Have you attached an example drawing

Posted

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

 

 

 

 

 

Capture.JPG

Posted (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 by aliscan
Posted

It will be in the same code. So while writing the area and length, it will also write the automatic number. thanks

Posted

 

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

 

 

 

 

 

Capture.JPG

  • Like 1
Posted

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

Posted

 

If I exited the command it would be nice if it asked which number to start with. thanks

Posted

 

If possible, create your own layer.

Thanks

Posted (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 by mhupp
added notes
Posted

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

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

 

 

 

 

 

Posted

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.

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