Author Topic: What am I missing here?  (Read 4572 times)

0 Members and 1 Guest are viewing this topic.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
What am I missing here?
« on: June 01, 2007, 01:13:39 PM »
Getting Error and is stopping at (itoa PlineID)
Quote
bad argument type: stringp nil

Code Snip
Quote
(defun c:A2R ()         ; / CE PlineID fieldstring ToRmnaTag)
  (vl-load-com)
  (vl-cmdf ".undo" "m")
;;  (setq ce (getvar "CMDECHO"))
;;  (setvar "CMDECHO" 1)


;;;; User Selection of Closed PolyLine
  (setq   PlineID   (vla-get-objectid
        (vlax-ename->vla-object
          (car (entsel "\n Select a closed polyline:  "))
        )
      )
  )

;;;; Generating of FeildString Variable
;;;; Use the FIELD command for the "Area"
  (setq   fieldstring
    (strcat
      "%<\AcObjProp.16.2 Object(%<\_ObjId"
      (itoa PlineID)
      ">%).Area \f "
      %lu2%pr1%zs8%ct8[0.006944444444444444]
      ">%"
    )
  )



I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

ronjonp

  • Needs a day job
  • Posts: 7529
Re: What am I missing here?
« Reply #1 on: June 01, 2007, 01:21:19 PM »
This needs quotes %lu2%pr1%zs8%ct8[0.006944444444444444]

You will also need to double up \ and add a \ before each "

Like so:

Code: [Select]
  (setq fieldstring
(strcat
   "%<\\AcObjProp.16.2 Object(%<\\_ObjId"
   (itoa PlineID)
   ">%).Area \\f "
   "\"%lu2%pr1%zs8%ct8[0.006944444444444444]\">%"
)
  )

Ron
« Last Edit: June 01, 2007, 01:28:39 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: What am I missing here?
« Reply #2 on: June 01, 2007, 01:42:40 PM »
This needs quotes %lu2%pr1%zs8%ct8[0.006944444444444444]
This makes sense.  I was coming to conclusion that this was the problem I but I made it worse instead of better.

You will also need to double up \ and add a \ before each "

Like so:
Ron
Thanks for the code.  At first I was Huh.


I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: What am I missing here?
« Reply #3 on: June 01, 2007, 02:01:21 PM »
Ahh now I am missing something new  :-P

Getting this with a piece of test mtext
Quote
AcObjProp.16.2 Object().Area

Updated code
Code: [Select]
(defun c:A2R (/) ;CE PlineID fieldstring ToRmnaTag)
  (princ)
  (vl-load-com)
  (vl-cmdf ".undo" "m")
;;;  (setq ce (getvar "CMDECHO"))
;;;  (setvar "CMDECHO" 1)


;;;; User Selection of Closed PolyLine
  (setq PlineID (vla-get-objectid
  (vlax-ename->vla-object
    (car (entsel "\n Select a closed polyline:  "))
  )
)
  )

;;;; Generating of FeildString Variable
;;;; Use the FIELD-command to compose the next line: 
(setq fieldstring
       (strcat
"%<\AcObjProp.16.2 Object(%<\_ObjId"
(itoa PlineID)
">%).Area \\f "
"\"%lu2%pr1%ct8[0.006944444444444444]\">%"
       )
)


  "%<\AcObjProp.16.2 Object(%<\_ObjId"
  (itoa PlineID)
  ">%).Area \\f ""%lu2%pr1%ct8[0.006944444444444444]\">%"

(vla-put-TextString
  (vlax-ename->vla-object
    (car
      (entsel "\n Select text entity to change: ")
    )
  )
  fieldstring
)

Quote from: from watch window
FIELDSTRING = "%<AcObjProp.16.2 Object(%<_ObjId2117772800>%).Area \\f \"%lu2%pr1%ct8[0.006944444444444444]\">%"
PLINEID = 2117772800

I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

T.Willey

  • Needs a day job
  • Posts: 5251
Re: What am I missing here?
« Reply #4 on: June 01, 2007, 02:07:34 PM »
Do you see the difference between the code for the variable 'fieldstring' between what Ron posted and what you have just posted?  This might be the problem.

Hint: Look at the \ 's
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: What am I missing here?
« Reply #5 on: June 01, 2007, 02:21:50 PM »
Do you see the difference between the code for the variable 'fieldstring' between what Ron posted and what you have just posted?  This might be the problem.

Hint: Look at the \ 's

Speed Kills   
This is very frustrating, this Stuff I thought I can put together myself.
I am not even to the meat of the routine yet where I know I would be need your guys help.

I am not out of the wood yet.
Okay it changing the mtext to a field but it instead of a number I am getting
Quote
####
Is the formating formating?

I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

T.Willey

  • Needs a day job
  • Posts: 5251
Re: What am I missing here?
« Reply #6 on: June 01, 2007, 02:23:52 PM »
I don't use fields, so I can't be of any help there.  Maybe if no one comes around that knows fields, and  I have some time I will look at that part.  Sorry can't be more help.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: What am I missing here?
« Reply #7 on: June 01, 2007, 02:27:52 PM »
I don't use fields, so I can't be of any help there.  Maybe if no one comes around that knows fields, and  I have some time I will look at that part.  Sorry can't be more help.

Thanks Tim.  This will be my second time at using fields.
Like I this one I thought I can get to work by myself but it is kicking my rear all over the place.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

ronjonp

  • Needs a day job
  • Posts: 7529
Re: What am I missing here?
« Reply #8 on: June 01, 2007, 03:08:28 PM »
Try this:

Code: [Select]
(defun c:A2R (/ plineid fieldstring) ;CE PlineID fieldstring ToRmnaTag)
  (princ)
  (vl-load-com)
  (vl-cmdf ".undo" "m")
  ;; User Selection of Closed PolyLine
  (setq PlineID (vla-get-objectid
  (vlax-ename->vla-object
    (car (entsel "\n Select a closed polyline:  "))
  )
)
  )
  ;; Generating of FeildString Variable
  ;; Use the FIELD-command to compose the next line: 
  (setq fieldstring
(strcat
   "%<\\AcObjProp.16.2 Object(%<\\_ObjId "
   (itoa PlineID)
   ">%).Area \\f \"%lu2%pr1%ct8[0.006944444444444444]\">%"
)
  )
  (vla-put-TextString
    (vlax-ename->vla-object
      (car
(entsel "\n Select text entity to change: ")
      )
    )
    fieldstring
  )
)

The other was not working because it was missing this space:

"%<\\AcObjProp.16.2 Object(%<\\_ObjId "

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: What am I missing here?
« Reply #9 on: June 01, 2007, 03:16:11 PM »
Try this:

The other was not working because it was missing this space:

"%<\\AcObjProp.16.2 Object(%<\\_ObjId "
Thanks RonJonp,

It is working now.
I look at that and added the space but getting no where so took the space back out.  I must have had something else screwed up at the time.

Off to go work on the other pieces, hopefully I will have better luck.

Thanks guys.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

ronjonp

  • Needs a day job
  • Posts: 7529
Re: What am I missing here?
« Reply #10 on: June 01, 2007, 03:18:06 PM »
Give this a try....if the text does not exist this will place new text in the bounding box of the polyline:

Code: [Select]
(defun c:a2r (/ obj fs doc ll ur pt)
  (vl-load-com)
  (setq obj (vlax-ename->vla-object
      (car (entsel "\n Select a closed polyline:  "))
    )
fs  (strcat
      "%<\\AcObjProp.16.2 Object(%<\\_ObjId "
      (itoa (vla-get-objectid obj))
      ">%).Area \\f \"%lu2%pr1%ct8[0.006944444444444444]\">%"
    )
doc (vla-get-ActiveDocument (vlax-get-acad-object))
  )
  (vla-getboundingbox obj 'll 'ur)
  (setq ll (vlax-safearray->list ll)
ur (vlax-safearray->list ur)
pt (vlax-safearray->list
     (vlax-variant-value
       (vlax-3d-point
(polar ll (angle ll ur) (/ (distance ll ur) 2.0))
       )
     )
   )
  )
  (vla-addText
    (if (= (getvar 'cvport) 1)
      (vla-get-paperspace doc)
      (vla-get-modelspace doc)
    )
    fs
    (vlax-3d-point pt)
    (if (= (getvar 'cvport) 1)
      0.125
      (* (getvar 'dimscale) 0.125)
    )
  )
)

Have a nice weekend.

Ron :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: What am I missing here?
« Reply #11 on: June 01, 2007, 03:33:00 PM »
Give this a try....if the text does not exist this will place new text in the bounding box of the polyline:
Thanks, I wont be passing it to text when all is said and done.  I am justing using the text part to test the first two parts.  I will eventually pass it to an attribute in a block  But I don't have that info form my boss yet.  However I will look into at your code to gain understanding.  :-)


Have a nice weekend.
Ron :)
  Thanks though I might be working for either for my boss here or my boss at home.  :-P
 and in 32 minutes I have to go meet a contractor at my house to see if it will be a good weekend or an expensive weekend.  :-o

So I will tell you monday how it works out
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans