Author Topic: How do I read some vla-object info ??  (Read 3165 times)

0 Members and 1 Guest are viewing this topic.

Hangman

  • Swamp Rat
  • Posts: 566
How do I read some vla-object info ??
« on: February 10, 2009, 05:02:26 PM »
So, I've tried doing a search but I don't even know what to search for so it's a bit mute.
I hope you guru's here can help me out once again.
This is what I have:
Code: [Select]
(defun c:TW (/ oldecho Sel FromObj ToObj)
  (defun $error (msg /)
    (if (or (= msg "Function cancelled") (/= msg "quit / exit abort"))
        (princ (strcat "Error: " msg))
    )
    (command ".redraw")
    (setvar "cmdecho" 1)
    (setq *error* old_err)
    (princ)
  );end error
  (setq old_err *error*
        *error* $error
        oldecho (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (and
    (setq Sel (nentsel "\n Select text/attribute to match properties from: "))
    (setq FromObj (vlax-ename->vla-object (car Sel)))
    (setq Sel (nentsel "\n Select text/attribute to match properties to: "))
    (setq ToObj (vlax-ename->vla-object (car Sel)))
    (mapcar
     '(lambda (x)
      (vlax-put ToObj x (vlax-get FromObj x)))
     '("ScaleFactor")
    )
  )
  (setvar "cmdecho" 1)
  (princ)
)
This code works superbly for transferring the "ScaleFactor" from one element to another.
I actually copied this and made another transferring the "TextString" from one element to another.

I am currently trying to modify the code a bit to access more of the entity being selected.  One is the Text Style.   Unfortunately, "TextStyle" does not work.
So, I've gotten this far in trying to read the elements of an entity like so:
Quote
Command: (setq Sel (nentsel))

Select object: (<Entity name: 7eb07d60> (658.932 134.802 0.0))

Command: !sel
(<Entity name: 7eb07d60> (658.932 134.802 0.0))

Command: (setq Obj (vlax-ename->vla-object (car Sel)))
#<VLA-OBJECT IAcadAttributeReference2 1163ff3c>

Command: !obj
#<VLA-OBJECT IAcadAttributeReference2 1163ff3c>

But, I don't know how to get all the info out of this variable:  #<VLA-OBJECT IAcadAttributeReference2 1163ff3c>
So, in essence;  I know I can change one line of code to get different effects out of the lisp routine (example:  ScaleFactor, TextString)
What else is this capable of ??  Where can I find a list of the possible uses of this ??  How can I extract a list of all the possible properties out of the 'Obj' variable from above ??

I hope these questions make sense, but if not please be patient with me and ask a lot of questions.
Thank you all very much.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How do I read some vla-object info ??
« Reply #1 on: February 10, 2009, 05:15:34 PM »
Try this:

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

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How do I read some vla-object info ??
« Reply #2 on: February 10, 2009, 05:16:03 PM »
ActiveX Help for LISPin' folks.

Also, look into the vlax-dump-object function, very useful.

Sorry, no time for more verbiage than that.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How do I read some vla-object info ??
« Reply #3 on: February 10, 2009, 05:16:33 PM »
Looks like some of my coding.

To see what properties/method you can extract per object with ActiveX, you can look in the help, or you can just dump the object variable.

(vlax-dump-object (vlax-ename->vla-object (car (entsel))) T)
Tim

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

Please think about donating if this post helped you.

Hangman

  • Swamp Rat
  • Posts: 566
Re: How do I read some vla-object info ??
« Reply #4 on: February 10, 2009, 05:41:54 PM »
Yes Sir Mr. Willey, it is your code, ...  from about two years ago.  Still going strong and still VERY MUCH appreciated.  You've helped me out a lot in the past and I will still say Thank you for your help and expertise.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hangman

  • Swamp Rat
  • Posts: 566
Re: How do I read some vla-object info ??
« Reply #5 on: February 10, 2009, 05:45:06 PM »
Thank you guys, I'll go play with this (vlax-dump-object) and see what I can get.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How do I read some vla-object info ??
« Reply #6 on: February 10, 2009, 06:01:09 PM »
Yes Sir Mr. Willey, it is your code, ...  from about two years ago.  Still going strong and still VERY MUCH appreciated.  You've helped me out a lot in the past and I will still say Thank you for your help and expertise.

You're welcome.  As long as you learned somethings, then my/our time has not been wasted.
Tim

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

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How do I read some vla-object info ??
« Reply #7 on: February 10, 2009, 06:02:16 PM »
At least you're dissecting code and asking questions...that's awesome :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Spike Wilbury

  • Guest
Re: How do I read some vla-object info ??
« Reply #8 on: February 10, 2009, 06:04:51 PM »
At least you're dissecting code and asking questions...that's awesome :)

and at least he also end up using....

Quote
Sir Mr.......


 :-D

Hangman

  • Swamp Rat
  • Posts: 566
Re: How do I read some vla-object info ??
« Reply #9 on: February 10, 2009, 06:25:03 PM »
I have learned a lot so it has not been wasted.  But I have to admit, about nine months ago the boss told me I could not write or update our lisp routines on company time.  So I've been trying to do so on my own time, working my own routines, nothing for the company.  (one of the reasons I have not been visiting as frequently as I have in the past)  I've been trying to expand my learning with VBA, VB script and Java.  But as a result, my lisp has really weakened.  Then over the past three months I have not been able to work with VB either, so I'm in bad shape at the moment.  You know how they say, "If you don't use it, you lose it", well ... I'm losing it!
Which brings me to this.  I punched this in and ...
Quote
(vlax-dump-object (vlax-ename->vla-object (car (entsel))) T)
Here's the results, cool.
Quote
Select object: ; IAcadBlockReference: AutoCAD Block Reference Interface
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00cdb528>
;   Document (RO) = #<VLA-OBJECT IAcadDocument 015cc778>
;   EffectiveName (RO) = "DESIGNPOINT"
;   Handle (RO) = "1A6A"
;   HasAttributes (RO) = -1
;   HasExtensionDictionary (RO) = 0
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 10e484f4>
;   InsertionPoint = (587.373 158.991 76.0639)
;   InsUnits (RO) = "Unitless"
;   InsUnitsFactor (RO) = 1.0
;   IsDynamicBlock (RO) = 0
;   Layer = "POINTSYMBOL"
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Material = "ByLayer"
;   Name = "DESIGNPOINT"
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 2125495632
;   ObjectName (RO) = "AcDbBlockReference"
;   OwnerID (RO) = 2126368672
;   PlotStyleName = "ByLayer"
;   Rotation = 0.0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 0ae06f90>
;   Visible = -1
;   XEffectiveScaleFactor = 978.357
;   XScaleFactor = 978.357
;   YEffectiveScaleFactor = 978.357
;   YScaleFactor = 978.357
;   ZEffectiveScaleFactor = 978.357
;   ZScaleFactor = 978.357
; Methods supported:
;   ArrayPolar (3)
;   ArrayRectangular (6)
;   ConvertToAnonymousBlock ()
;   ConvertToStaticBlock (1)
;   Copy ()
;   Delete ()
;   Explode ()
;   GetAttributes ()
;   GetBoundingBox (2)
;   GetConstantAttributes ()
;   GetDynamicBlockProperties ()
;   GetExtensionDictionary ()
;   GetXData (3)
;   Highlight (1)
;   IntersectWith (2)
;   Mirror (2)
;   Mirror3D (3)
;   Move (2)
;   ResetBlock ()
;   Rotate (2)
;   Rotate3D (3)
;   ScaleEntity (2)
;   SetXData (2)
;   TransformBy (1)
;   Update ()
T
In the code I posted initially, where is the "TextString" being pulled from ??  (I am assuming it is part of the 'GetXData' and the (3) is how many items are available in the method) ?.?  But the 'ScaleEntity' is it's own method so I'm a bit confused with the differences of these two items.
Also, if I am wanting to pull the text style of the entity, would I pull that from the GetXData method ??
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How do I read some vla-object info ??
« Reply #10 on: February 10, 2009, 06:33:54 PM »
You picked an insert, so there is no ' TextString ' property.  If you want to select an attribute, then use ' nentsel ' instead of ' entsel '.
Tim

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

Please think about donating if this post helped you.

Hangman

  • Swamp Rat
  • Posts: 566
Re: How do I read some vla-object info ??
« Reply #11 on: February 10, 2009, 07:02:57 PM »
Oh yes, overlooked that dang'it, thank you.
I've gotta run now, but I'll try to be back tomorrow with more questions.  Thank you all very much for your help and insight.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

dustinthiesse

  • Guest
Re: How do I read some vla-object info ??
« Reply #12 on: February 11, 2009, 08:23:32 AM »
Just wondering, Hangman, do you use the VLIDE editor in autocad?

If so, you can perform an "inspect" on any variable and the inspect window will list all the properties of the object.
Some of the values make more sense there (like :vlax-true or :vlax-false for the HasAttributes property instead of -1 or 0).
Plus, you can double-click on a property and it will display a new inspect window for that object.