Author Topic: Scale value of a Viewport  (Read 11723 times)

0 Members and 1 Guest are viewing this topic.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Scale value of a Viewport
« Reply #15 on: November 09, 2006, 01:35:07 PM »
The methods and properties are ActiveX controls of the object.  They are pretty much the same as VBA.  To see and explanation look in the help files.  Get to the 'Developer Documentation' and then you will see a section called 'ActiveX and VBA Developer's Guide'.  In there you will see sections for properties, methods and objects, these are what you are looking for.  They are explained in VBA terms, so the syntax is a little different, but you have many people here who know what they are doing, so if the help isn't enough post a question.

Thanks Tim,

From what I gather from a quick pass am I correct to assume that I can not edit the text string, I have to delete the text and recreate it with the new text string?  I wonder if there is a Replace function?  I was really looking for just editing because the end goal routine is this will be an optional tool to my users.  I have a bunch of dinosaurs (sorry dino not you) that prefer to make multiple clicks to do same thing that a lisp can do.  I can't change that thought so therefore my tools or routines are distributed or set up for optional use. 
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: Scale value of a Viewport
« Reply #16 on: November 09, 2006, 02:06:23 PM »
From what I gather from a quick pass am I correct to assume that I can not edit the text string, I have to delete the text and recreate it with the new text string?
Nope, you can change the string of an existing text string.
Code: [Select]
(vla-put-TextString
 (vlax-ename->vla-object
  (car
   (entsel "\n Select text entity to change: ")
  )
 )
 "This is a test!!"
)

Is this what you were thinking?  Sorry if I misinterpreted your intentions.
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: Scale value of a Viewport
« Reply #17 on: November 09, 2006, 02:22:24 PM »
From what I gather from a quick pass am I correct to assume that I can not edit the text string, I have to delete the text and recreate it with the new text string?
Nope, you can change the string of an existing text string.
Code: [Select]
(vla-put-TextString
 (vlax-ename->vla-object
  (car
   (entsel "\n Select text entity to change: ")
  )
 )
 "This is a test!!"
)

Is this what you were thinking?  Sorry if I misinterpreted your intentions.
No that is what I am exactly looking for.
Thanks. Now I am going to hack all this together. 
Thanks Tim & Matt.
I will be back.
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: Scale value of a Viewport
« Reply #18 on: November 09, 2006, 02:45:50 PM »
Good to hear Krushert.  One thing, not sure if you know or not, but when using the ActiveX controls in Lisp, you need to call (vl-load-com) at least once per Acad session, more is okay.

Let us know when you need help/finish your program.  Have fun.
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: Scale value of a Viewport
« Reply #19 on: November 09, 2006, 03:40:49 PM »
Good to hear Krushert.  One thing, not sure if you know or not, but when using the ActiveX controls in Lisp, you need to call (vl-load-com) at least once per ACAD session, more is okay.

Let us know when you need help/finish your program.  Have fun.
basicly you guys gave it all to me.  I swap your Put-textstring in lieu of Matt's addtext and then clean it up.

Code: [Select]
;;; VPort-Scale Lisp  11/09/2006  Ted Krush with a lot help from TheSwamp.org
;;; Adds the viewport scale factor to an existing textstring with use of a feild
;;;
(defun c:vpsc (/ ID)
  (princ)
  (vl-cmdf ".undo" "m")
  (vl-load-com)
  (setq ID (vla-get-objectid
     (vlax-ename->vla-object
       (car (entsel "\n Select Viewport Entity "))
     )
   )
  )

  (vla-put-TextString
    (vlax-ename->vla-object
      (car
(entsel "\n Select text entity to change: ")
      )
    )
    (strcat "SCALE: "
    "%<\\AcObjProp Object(%<\\_ObjId "
    (itoa ID)
    ">%).CustomScale \\f \"%lu4%pr8%ct2%qf2816 = 1'-0\\\"\">%"
    )
  )
  (princ)
)
This is a major time saver. and I did have fun.  :-)

Mucho 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

Guest

  • Guest
Re: Scale value of a Viewport
« Reply #20 on: November 09, 2006, 03:46:49 PM »
One slight change!

Quote
;;; VPort-Scale Lisp  11/09/2006  Ted Krush with a lot help from TheSwamp.org
;;; Adds the viewport scale factor to an existing textstring with use of a feild
;;;
(defun c:vpsc (/ ID)

I think I'm gonna pirate a copy of this and use to change entity values to the CTAB value.  We use that in our title blocks and just rename the layout tabs; also used for batch plotting.

Glad you got it working... I was having a heck of a time with this part:
Quote
1'-0\\\"\">%"
The slashes and quotes were throwing me for a loop.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Scale value of a Viewport
« Reply #21 on: November 09, 2006, 04:06:00 PM »
One slight change!

Quote
;;; VPort-Scale Lisp  11/09/2006  Ted Krush with a lot help from TheSwamp.org
;;; Adds the viewport scale factor to an existing textstring with use of a feild
;;;
(defun c:vpsc (/ ID)
Thanks for letting me know about my spelling.  I wish Lisp editor had a spell check.

Glad you got it working... I was having a heck of a time with this part:
Quote
1'-0\\\"\">%"
The slashes and quotes were throwing me for a loop.
Yeah what is that line doing  anyway
Code: [Select]
    ">%).CustomScale \\f \"%lu4%pr8%ct2%qf2816 = 1'-0\\\"\">%"
No that is what I am exactly looking for.
Thanks. Now I am going to hack all this together. 
Thanks Tim & Matt & Ronjonp[
I will be back.
Sorry Ronjonp  :oops:  I was interrupted and hit the post.
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

Guest

  • Guest
Re: Scale value of a Viewport
« Reply #22 on: November 09, 2006, 04:16:51 PM »
Yeah what is that line doing  anyway
Code: [Select]
    ">%).CustomScale \\f \"%lu4%pr8%ct2%qf2816 = 1'-0\\\"\">%"
It's basically telling the text (or mtext or whatever) how to display the viewport's scale.

The attached image might help to explain things better.

All of this gobble-dee-goop (CustomScale \\f \"%lu4%pr8%ct2%qf2816 = 1') is contained in the field expression section at the bottom of the dialog box.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Scale value of a Viewport
« Reply #23 on: November 09, 2006, 04:26:43 PM »
Yeah what is that line doing  anyway
Code: [Select]
    ">%).CustomScale \\f \"%lu4%pr8%ct2%qf2816 = 1'-0\\\"\">%"
It's basically telling the text (or mtext or whatever) how to display the viewport's scale.

The attached image might help to explain things better.

All of this gobble-dee-goop (CustomScale \\f \"%lu4%pr8%ct2%qf2816 = 1') is contained in the field expression section at the bottom of the dialog box.

Ah hah.
hmmmmmm.  me thinking.
I might modify something else too. 
Thanks.
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: Scale value of a Viewport
« Reply #24 on: November 09, 2006, 05:20:53 PM »
Glad you got what you were looking for :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Scale value of a Viewport
« Reply #25 on: November 09, 2006, 05:29:20 PM »
One slight change!

Quote
;;; VPort-Scale Lisp  11/09/2006  Ted Krush with a lot help from TheSwamp.org
;;; Adds the viewport scale factor to an existing textstring with use of a feild
;;;
(defun c:vpsc (/ ID)

I think I'm gonna pirate a copy of this and use to change entity values to the CTAB value.  We use that in our title blocks and just rename the layout tabs; also used for batch plotting.

Glad you got it working... I was having a heck of a time with this part:
Quote
1'-0\\\"\">%"
The slashes and quotes were throwing me for a loop.



We do the same thing here with the CTAB field....thanks for the idea.
Code: [Select]
(defun c:ctabfield (/)
  (vla-put-TextString
    (vlax-ename->vla-object
      (car (entsel "\n Select text: "))
    )
    "%<\\AcVar ctab \\f \"%tc1\">%"
  )
  (princ)
)

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Guest

  • Guest
Re: Scale value of a Viewport
« Reply #26 on: November 09, 2006, 07:41:29 PM »
Quote
We do the same thing here with the CTAB field....thanks for the idea.
You're welcome.