Jump to content

Fill table cells with fields


spasobn

Recommended Posts

Hi, thank you, but there must be some mistake, because the script is not executed. It is may be in brackets or anythink else worse in it, but I don't undestand its syntax. Please look at it once more.

 

I replaced

                              (vlax-3D-point (trans '(0 0 1) 0 1)) 'row 'col)) nil

with

                              (vlax-3D-point (trans (getvar 'viewdir) 1 0 T)) 'row 'col)) nil

Link to comment
Share on other sites

  • Replies 44
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    13

  • spasobn

    12

  • VAC

    7

  • m4rdy

    2

Top Posters In This Topic

Posted Images

I overlooked the fact that the picked cell point has to be translated to the WCS:

(defun c:sCell (/ 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 Room: ")))
       (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 (trans pt 1 0))
                              (vlax-3d-point (trans (getvar 'viewdir) 1 0 T)) 'row 'col)) nil
                  (princ "\n** No Cell Selected **")))
               (t (princ "\n** No Point Selected **")))))
     (vla-setText tObj row col
       (strcat
         "%<\\AcObjProp Object(%<\\_ObjId " (LM:objectid (vlax-ename->vla-object ent)) ">%).Area \\f \"%lu2%pr2%ds44%ct8[1e-006]\">%")))
   (princ "\n** No Table Selected **"))
 (princ))

 

Link to comment
Share on other sites

  • 3 months later...

Hi, script works fine for me. I have one more question. I need to multiply the obtained area value by X, (for ex. 2times).

First, it shoud by set at the beginning of the script like

(setg multiplier 2)

 and how, to implement it to the script, I think it shoud be in this line?

 

       (strcat
         "%<\\AcObjProp Object(%<\\_ObjId " (LM:objectid (vlax-ename->vla-object ent)) ">%).Area \\f \"%lu2%pr2%ds44%ct8[1e-006]\">%"))

or better

second way, script will ask me with the dialog at the begining of the script for variable "multiplier"

 

Thank you

Link to comment
Share on other sites

Hi, script works fine for me. I have one more question. I need to multiply the obtained area value by X, (for ex. 2times).

First, it shoud by set at the beginning of the script like  "

(setg multiplier 2)

  how, to implement it I think to this line?

 

       (strcat
         "%<\\AcObjProp Object(%<\\_ObjId " (LM:objectid (vlax-ename->vla-object ent)) ">%).Area \\f \"%lu2%pr2%ds44%ct8[1e-006]\">%"))

or better

second way, script will ask me with the dialog at the begining of the script for variable "multiplier"

 

Thank you

 

-------------------------

 

I find out answer to my both questions:

 (setq multiplier (getdist "\nSet multiplier")

and

"%<\\AcExpr (%<\\AcObjProp Object(%<\\_ObjId " (LM:objectid (vlax-ename->vla-object ent)) ">%).Area>%*multiplier) \\f \"%lu2%pr2%ds44%ct8[1e-006]\">%")))

 

Link to comment
Share on other sites

  • 1 year later...

Hi, LeeMac

On 7/9/2009 at 8:50 PM, Lee Mac said:

This will put your fields into cells in a table.

 

 

  • Select your table.
  • Select your rooms in turn.
  • Click inside the cell you want the field in.

 


(defun c:sCell (/ 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 Room: ")))
       (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\">%")))
   (princ "\n** No Table Selected **"))
 (princ))
                
       
 

 

 

Thank you for your solution. For some reason, when I try to implement it using polylines, the field in cell shows ####. Any ideas on how to fix it?

Thank you!

Link to comment
Share on other sites

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