Author Topic: How to convert Field to String to use in Entmake in the code  (Read 2581 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1421
How to convert Field to String to use in Entmake in the code
« on: December 10, 2019, 08:39:52 AM »
I am wondering is it possible to convert a field to a string to use in Entmakex
 
I extracted the scale using
Code - Auto/Visual Lisp: [Select]
  1.     (setq enam (car (nentsel "\nSelect Viewport: ")))
  2.     (setq objid (vla-get-objectid (vlax-ename->vla-object enam)))
  3.     (setq fldexp (strcat "Scale : " "%<\\AcObjProp Object(%<\\_ObjId " (itoa objid) " >%).StandardScale2 \\f \"%en0\">%"))


Thanks in advance



ronjonp

  • Needs a day job
  • Posts: 7527
Re: How to convert Field to String to use in Entmake in the code
« Reply #1 on: December 10, 2019, 09:03:35 AM »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: How to convert Field to String to use in Entmake in the code
« Reply #2 on: December 10, 2019, 01:41:44 PM »
I am wondering is it possible to convert a field to a string to use in Entmakex

I would advise against using entmake(x) to create a field as it requires a not insignificant amount of code to create the associated extensionary dictionaries which underpin the field functionality; conversely, a simple (vla-put-textstring <obj> <field expression>) using ActiveX will create such dictionaries for you automatically.

HasanCAD

  • Swamp Rat
  • Posts: 1421
Re: How to convert Field to String to use in Entmake in the code
« Reply #3 on: December 11, 2019, 12:29:49 AM »
I am trying to modify LEE lisp http://www.lee-mac.com/vpoutline.html  (Thanks LEE)
to add sheet number and scale of the viewport but I the result like attached
Due to the viewport in a layout and the text in model
So What comes in mind to convert the field to string and I am asking for thant.

HasanCAD

  • Swamp Rat
  • Posts: 1421
Re: How to convert Field to String to use in Entmake in the code
« Reply #4 on: December 11, 2019, 04:19:33 AM »
When close the file and open again it works
Thanks for all

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: How to convert Field to String to use in Entmake in the code
« Reply #5 on: December 11, 2019, 10:19:42 PM »
Using VL you can set the viewport scale

(vla-put-CustomScale viewport yourscale)

Then use zoom c scale
A man who never made a mistake never made anything

ronjonp

  • Needs a day job
  • Posts: 7527
Re: How to convert Field to String to use in Entmake in the code
« Reply #6 on: December 12, 2019, 11:20:03 AM »
When close the file and open again it works
Thanks for all
You might check your FIELDEVAL setting too.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

PKENEWELL

  • Bull Frog
  • Posts: 317
Re: How to convert Field to String to use in Entmake in the code
« Reply #7 on: December 12, 2019, 03:51:31 PM »
When close the file and open again it works
Thanks for all

Perhaps incorporate a call to the command UPDATEFIELD and select the previously created text?
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt