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

0 Members and 1 Guest are viewing this topic.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Scale value of a Viewport
« on: November 08, 2006, 02:30:54 PM »
Is there way to extract the value of user selected viewport.

I am wanting to write a routine revise a piece of text  base upon the scale of viewport.

Thanks.  I am getting tired of constantly updating my con doc grids

Oh by the way I am loving Firefox 2.0.  Automatic spell check Swweeeeeeeeettttttt :-)

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 #1 on: November 08, 2006, 02:54:53 PM »
You can use a field.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Scale value of a Viewport
« Reply #2 on: November 08, 2006, 02:58:45 PM »
Hi, 

assuming ent is the viewport ename :

(/ (cdr (assoc 41 (entget ent))) (cdr (assoc 45 (entget ent))))

or :

(vla-get-CustomScale (vlax-ename->vla-object ent))

If the viewport is active, you can just do :

(caddr (trans '(0 0 1) 2 3))
« Last Edit: November 08, 2006, 03:01:44 PM by gile »
Speaking English as a French Frog

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Scale value of a Viewport
« Reply #3 on: November 08, 2006, 03:47:34 PM »
You can use a field.
[voice of grass hopper]
I have heard of what you speak Master but I have concerns of the unknown.  Please explain.
[/voice]
Sorry the last 4 days have been 15 hour days of work.


(vla-get-CustomScale (vlax-ename->vla-object ent))
Thanks that got me what I needed. 
Now I just need to get it in the right format of Fractions   :-)

 
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 #4 on: November 08, 2006, 04:12:55 PM »
Quote
[voice of grass hopper]
I have heard of what you speak Master but I have concerns of the unknown.  Please explain.
[/voice]
See attached video (hope this helps).

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Scale value of a Viewport
« Reply #5 on: November 08, 2006, 04:50:37 PM »
Thanks that did help. 
two things that I like about it were
  • it is linked to the viewport.  My original track was not going to be linked
  • It takes care of the formating issue of fractions.  I was having a hard time converting the decimal value to fractions.
my concerns are:
  • how could I automate this so that the user has just two picks;  the view port & and the text to change?
  • If the viewport is deleted, what happens to the field?

I am trying to make this simple as possible for my users.
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 #6 on: November 08, 2006, 05:01:40 PM »
Quote
how could I automate this so that the user has just two picks;  the view port & and the text to change?
See code below.  It's for adding an area field as mtext based on a close pline selection.  You should be able to hack it to work with vports.  I'm not well-versed in the ways of VLISP so....

Quote
If the viewport is deleted, what happens to the field?
The text would read as four dashes (---) because the info can't be found.

Code: [Select]
(defun C:FIELD-Area (/ a s1 index ent obj obj_ID txt)

   (vl-load-com)
   ;;get a reference to model space
   (setq *model-space*
          (vla-get-ModelSpace
            (vla-get-ActiveDocument (vlax-get-acad-object))
          )
   )

   ;; Set A = the entity and set B = Point for text
   (setq a (car (entsel)) b (getpoint "\n Select Point: "))
   ;;Call the function
   (linkedarea a b)
)


; From R.K. McSwain
; http://rkmcswain.blogspot.com/2006/09/create-field-linked-to-object.html

;;pass this function an entity and a point
(defun LinkedArea (ent pt / obj objID ip width str) 
;;convert the entity to an object
  (setq obj
   (vlax-ename->vla-object ent)
        ;;get the object ID
        objID (vla-get-objectid obj)
        ;;convert the point
        ip    (vlax-3D-Point pt)
        ;;set the width for the MTEXT
        width 0.0
        ;;set the string - this creates the field
        str   (strcat
                "%<\\AcObjProp Object(%<\\_ObjId "
                (rtos objID 2 0)
                ">%).Area \\f \"%lu2>%"
              )
  )
   ;;Create the MTEXT entity containing the field.
  (vla-addMText *model-space* ip width str)
)

(princ)


Hope this helps.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Scale value of a Viewport
« Reply #7 on: November 08, 2006, 05:10:34 PM »
Thanks.  I not well verse in Vlisp either but I am excellent hacker.  :-D
I will tear it apart tomorrow.
Thanks.  Now off to some Guinness and pasta  ^-^

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 #8 on: November 08, 2006, 06:11:51 PM »
Give this a try:

Code: [Select]
(defun c:vp-scl (/ ID pt)
  (vl-load-com)
  (setq ID (vla-get-objectid (vlax-ename->vla-object (car (entsel))))
pt (vlax-3D-Point (getpoint "\n Select Point: "))
  )
  (vla-addMText
    (vla-get-paperspace
      (vla-get-ActiveDocument (vlax-get-acad-object))
    )
    pt
    0.0
    (strcat
      "%<\\AcObjProp Object(%<\\_ObjId "
      (itoa ID)
      ">%).CustomScale \\f \"1:%lu2%ct1%qf2816\">%"
    )
  )
)
« Last Edit: November 08, 2006, 06:16:50 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Andrea

  • Water Moccasin
  • Posts: 2372
Keep smile...

Guest

  • Guest
Re: Scale value of a Viewport
« Reply #10 on: November 09, 2006, 08:57:52 AM »
Give this a try:

Code: [Select]
(defun c:vp-scl (/ ID pt)
  (vl-load-com)
  (setq ID (vla-get-objectid (vlax-ename->vla-object (car (entsel))))
pt (vlax-3D-Point (getpoint "\n Select Point: "))
  )
  (vla-addMText
    (vla-get-paperspace
      (vla-get-ActiveDocument (vlax-get-acad-object))
    )
    pt
    0.0
    (strcat
      "%<\\AcObjProp Object(%<\\_ObjId "
      (itoa ID)
      ">%).CustomScale \\f \"1:%lu2%ct1%qf2816\">%"
    )
  )
)

Nice!  I think I can hack away at this to do other wonderous things.   Hmmmm.... :roll:

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Scale value of a Viewport
« Reply #11 on: November 09, 2006, 09:37:14 AM »
Give this a try:

Quote
(defun c:vp-scl   (/ ID pt)
.................
(vla-addMText)
    (vla-get-paperspace
      (vla-get-ActiveDocument (vlax-get-acad-object))

    (strcat
      "%<\\AcObjProp Object(%<\\_ObjId "
      (itoa ID)
      ">%).CustomScale \\f \"1:%lu2%ct1%qf2816\">%"
Thanks.   :-)
However I need to change a piece of DText.  The existing text (up to 16 instances) comes in on a CON DOC grid.
From > Scale:
To    > Scale: 1/4" = 1'-0

Like I said before I know nothing about VLA functions.

<Side note> How do I search in the Help for "ALL"  VLA functions pertaining to a certain object (or entity)?  Like this, I want to return all functions that handle (?? bad term) text.


http://www.google.ca/search?hl=fr&q=vpscale+lisp&meta=
Thanks Andrea I look at and it seems that it was similar to what RonJonp posted.  I did not try it, however if it if it is different from what Ronjonp's please let me know.
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 #12 on: November 09, 2006, 11:16:10 AM »
I use this to get an object's properties:

Code: [Select]
(defun c:vlaxprop (/)
  (vlax-dump-object
    (vlax-ename->vla-object
      (car (entsel "\nSelect Entity to Display it's Data: "))
    )
    T
  )
  (textscr)
)

This code below will output the text as "Scale: 1' = 1'-0"

Code: [Select]
(defun c:vp-scl (/ ID pt)
  (vl-load-com)
  (setq ID (vla-get-objectid (vlax-ename->vla-object (car (entsel))))
pt (vlax-3D-Point (getpoint "\n Select Point: "))
  )
  (vla-addMText
    (vla-get-paperspace
      (vla-get-ActiveDocument (vlax-get-acad-object))
    )
    pt
    0.0
    (strcat "Scale: "
      "%<\\AcObjProp Object(%<\\_ObjId "
      (itoa ID)
      ">%).CustomScale \\f \"%lu4%pr8%ct2%qf2816 = 1'-0\\\"\">%"
    )
  )
)


Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Scale value of a Viewport
« Reply #13 on: November 09, 2006, 12:29:11 PM »
I use this to get an object's properties:

Code: [Select]
(defun c:vlaxprop (/)
  (vlax-dump-object
    (vlax-ename->vla-object
      (car (entsel "\nSelect Entity to Display it's Data: "))
    )
    T
  )
  (textscr)
)

Wow what did you give me???  I feel like a small time crook that some how found himself in the big leagues.  8-) :-o :-D

See screen capture.

I see it return the property or data of object which by the way is the object that I want to insert the field into.  And I understand most of it, I think.

What is the second group "methods supported" do?  And what does the number in the bracket mean?
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 #14 on: November 09, 2006, 12:50:42 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.
Tim

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

Please think about donating if this post helped you.