Area into table Field

Area into table Field

malarcad
Participant Participant
940 Views
3 Replies
Message 1 of 4

Area into table Field

malarcad
Participant
Participant

 

Area into table Field

How to add multiple objects in this code below?

 

 

 

 

(defun c:test(/ tab ent Obj pt tObj row col)
(vl-load-com)
(if (and (setq tab (car (entsel "\nSelect Table: ")))
(eq "ACAD_TABLE" (cdr (assoc 0 (entget tab)))))
(while
(and

(setq ent (car (entsel "\nSelect Object: ")))
(vlax-property-available-p
(setq Obj
(vlax-ename->vla-object ent)) 'Area))


(while
(progn
(setq pt (getpoint "\nClick into Cell to place field: "))
(cond ((vl-consp pt)
(if (eq :vlax-true
(vla-hittest
(setq tObj
(vlax-ename->vla-object tab))
(vlax-3D-point pt)
(vlax-3D-point (trans '(0 0 1) 0 1)) 'row 'col)) nil
(princ "\n** No Cell Selected **")))
(t (princ "\n** No Point Selected **")))))
(vla-setText tObj row col
(strcat
"%<\\AcObjProp Object(%<\\_ObjId "
(vl-princ-to-string
(vla-get-Objectid Obj))
">%).Area \\f \"%lu2%pr2%ps[, Sq m]\">%")))
(princ "\n** No Table Selected **"))
(princ))

 

941 Views
3 Replies
Replies (3)
Message 2 of 4

dbroad
Mentor
Mentor

Really good attempt. You made a few errors that I corrected in the code below:

(defun c:test (/ tab ent Obj pt tObj row col)
  (vl-load-com)
  (if (and (setq tab (car (entsel "\nSelect Table: ")))
	   (eq "ACAD_TABLE" (cdr (assoc 0 (entget tab))))
      )
    (while
      (and

	(setq ent (car (entsel "\nSelect Object with Area: ")));<-prompt was too vague
	(vlax-property-available-p
	  (setq	Obj
		 (vlax-ename->vla-object ent)
	  )
	  'Area
	)
      )


       (while (or (null row) (null col)) ;<-Needed a test
	 (setq pt (getpoint "\nClick into Cell to place field: "));<-No progn needed
	 (cond ((vl-consp pt)
		(if (eq	:vlax-true
			(vla-hittest
			  (setq	tObj
				 (vlax-ename->vla-object tab)
			  )
			  (vlax-3D-point pt)
			  (vlax-3D-point (trans '(0 0 1) 1 0)) ;<- 1 and 0 backwards
			  'row
			  'col
			)
		    )
		  nil
		  (princ "\n** No Cell Selected **")
		)
	       )
	       (t (princ "\n** No Point Selected **"))
	 )
       )
       (vla-setText
	 tObj
	 row
	 col
	 (strcat
	   "%<\\AcObjProp Object(%<\\_ObjId "
	   (itoa ;;<---itoa works in most cases. vl-princ-to-string doesn't
	     (vla-get-Objectid Obj)
	   )
	   ">%).Area \\f \"%lu2%pr2%ps[, Sq m]\">%"
	 )
       )
    )
    (princ "\n** No Table Selected **")
  )
  (princ)
)
Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 3 of 4

malarcad
Participant
Participant

Thank u sir

0 Likes
Message 4 of 4

murugan_pg
Explorer
Explorer

Please send me any sample drawings for area in to table field Smiley Happy

0 Likes