Author Topic: Text number into field  (Read 1770 times)

0 Members and 1 Guest are viewing this topic.

REGHUYES

  • Newt
  • Posts: 21
Text number into field
« on: September 16, 2012, 04:56:24 AM »
Pls help me ..How to convert text value ( numbers only) into field in the below code.


(defun c:rll(/ pt1 pt2 pt3 LxW)
      (vl-load-com)
      (setq pt1 (getpoint "\nLower Left Corner:")
            pt3 (getcorner pt1 "\nUpper Right  Corner:"))
      (setq pt2 (list (car pt1) (cadr pt3) 0.0))
      (setq LxW (list (distance pt1 pt2) (distance pt2 pt3)))
      (vlax-invoke
            (vlax-get
                  (vla-get-ActiveLayout
                        (vla-get-activedocument
                              (vlax-get-acad-object)))
                  'Block)
            'AddmText
            (getpoint "\nPick point for text:")
            0.0
            (strcat (rtos (cadr LxW) 2 2)
                    "X"
                    (rtos (car LxW) 2 2)
                    )
            )
      )

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: Text number into field
« Reply #1 on: September 16, 2012, 05:44:09 AM »
What object property or drawing property would the Field Expression reference? Field Expressions cannot reference arbitrary points in space (and in any case, these would be constant hence the Field would never update), and it appears from your code that you wish to create a Field to display two lengths calculated from arbitrary points in space.

I'm guessing that you in fact wish to select an object in the drawing and create a Field referencing the rectangular length and width of the object, however, since the such dimensions are not found in the properties of any drawing objects, there is no object property for the Field Expression to reference.

If I have indeed understood your intentions, I believe you would need to use an Object Reactor to monitor modification to a notifier object and update the MText accordingly in the reactor callback function.

PS: Formatting code in your posts.