Author Topic: How to Improve an Attribute Edit  (Read 732 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2085
How to Improve an Attribute Edit
« on: June 08, 2024, 06:43:00 AM »
I am using LeeMac's LM:vl-setattributevalue routine (thanks Lee) to edit an existing Room Name attribute block with ceiling height and room size. I have hacked together the code below and was wondering on how to improve on it.


Code - Auto/Visual Lisp: [Select]
  1. (defun C:SQRM  (/ P1 P2)
  2.   (setvar "Cmdecho" 0)
  3.   (Initget 1)  
  4.   (setq P1 (Getpoint "\n* Pick first corner of Rectangle *"))
  5.   (setvar "Lastpoint" P1)
  6.   (Initget 1)
  7.   (setq P2 (Getcorner P1 "\n* Pick opposite corner of Rectangle *"))
  8.     "Pline"
  9.     P1
  10.     (List (Car P1) (Cadr P2)) ;;height of room
  11.     P2
  12.     (List (Car P2) (Cadr P1)) ;;width of room
  13.     "c")
  14.   (LM:vl-setattributevalue (vlax-ename->vla-object (car (entsel))) "NOTE2" (strcat (rtos (- (Car P2)(Car P1)) 4 0) " x " (rtos (- (Cadr P2)(Cadr P1)) 4 0)))  
  15.   (princ))
  16.  
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8903
  • AKA Daniel
Re: How to Improve an Attribute Edit
« Reply #1 on: June 08, 2024, 07:18:34 AM »
I need a flex room

BIGAL

  • Swamp Rat
  • Posts: 1459
  • 40 + years of using Autocad
Re: How to Improve an Attribute Edit
« Reply #2 on: June 09, 2024, 12:17:43 AM »
I dont understand how your getting ceiling height if you use thickness can read the ceiling height, see image walls are lines.


If you use Bpoly can make an internal pline of a shape so long as its closed can be multiple objects just has to be closed. Can then get min max etc in X & Y direction or use bounding box.

Not sure what object the 17-3x24-4 refers to ?
A man who never made a mistake never made anything

GDF

  • Water Moccasin
  • Posts: 2085
Re: How to Improve an Attribute Edit
« Reply #3 on: June 09, 2024, 09:16:41 PM »
Thanks BIGAL

Correction to code above: (List (Car P1) (Cadr P2)) ;;length of room
Only works for rectangular rooms.

I forgot about the bploy command, now using it to get the square footage:
Code - Auto/Visual Lisp: [Select]
  1. (defun C:RMAREA (/ OUTL OUTLSF)
  2.   ;;(C:00)
  3.   ;;(ARCH:F_S-VAR)
  4.   (command "-layer" "set" "0" "off" "~0*" "on" "*WALL*,*HEAD*,*GLAZ*" "")
  5.   ;;(ARCH:LYR "X-OUTL")
  6.   (command "bpoly")
  7.   (while (= 1 (logand 1 (getvar 'cmdactive))) (command "\\"))  
  8.   (command "-layer" "on" "*" "thaw" "*" "")
  9.   (if (/= (ssget "A" '((8 . "X-OUTL"))) nil)
  10.     (progn (setq OUTL
  11.                   (cdr
  12.                     (assoc -1
  13.                            (entget (ssname (ssget "A" '((8 . "X-OUTL"))) 0)))))
  14.            (command "AREA" "o" OUTL)
  15.            (setq OUTLSF (strcat "" (rtos (/ (getvar "AREA") 144) 2 0) " sf"))
  16.            (LM:vl-setattributevalue (vlax-ename->vla-object (car (entsel))) "NOTE3" OUTLSF)
  17.   ))
  18.   (if (/= (ssget "A" '((8 . "X-OUTL"))) nil) (command "erase" (ssget "A" '((8 . "X-OUTL"))) ""))
  19.   ;;(ARCH:F_R-VAR)
  20.   ;;(C:OFA)
  21.   (princ))
  22.  
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

BIGAL

  • Swamp Rat
  • Posts: 1459
  • 40 + years of using Autocad
Re: How to Improve an Attribute Edit
« Reply #4 on: June 10, 2024, 08:26:45 PM »
I think code can be shrunk a bit

Code: [Select]
(command "bpoly" (getpoint "\pick point near outside "))
(setq ent (entlast))
(setq area (vlax-get (vlax-ename->vla-object ent) 'Area))
(command "erase" ent "")
 

Just a comment if you leave all layers on and say use a layer like "Dummy" then do bpoly you will end up with lots of plines, but its easy to get them via "SSGET" and look up their area saving the largest, that is probably how I would do it. Then erase the selection set maybe also erase or purge layer Dummy. UsingVL get 'Area much easier.
« Last Edit: June 10, 2024, 08:31:41 PM by BIGAL »
A man who never made a mistake never made anything

GDF

  • Water Moccasin
  • Posts: 2085
Re: How to Improve an Attribute Edit
« Reply #5 on: June 11, 2024, 01:12:37 PM »
Thanks
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64