Author Topic: Visual LISP Question: Object Methods  (Read 3561 times)

0 Members and 1 Guest are viewing this topic.

nivuahc

  • Guest
Visual LISP Question: Object Methods
« on: May 13, 2005, 12:20:16 PM »
Where can I find more information about the available methods once I do a vlax-dump-object? For instance, I see that the available methods for an attribute I've selected are

Code: [Select]
; Methods supported:
;   ArrayPolar (3)
;   ArrayRectangular (6)
;   Copy ()
;   Delete ()
;   GetBoundingBox (2)
;   GetExtensionDictionary ()
;   GetXData (3)
;   Highlight (1)
;   IntersectWith (2)
;   Mirror (2)
;   Mirror3D (3)
;   Move (2)
;   Rotate (2)
;   Rotate3D (3)
;   ScaleEntity (2)
;   SetXData (2)
;   TransformBy (1)
;   Update ()


Now what? Where can I find out exactly what I can and cannot do with those methods. Let's say, for example, I wanted to ScaleEntity using, I assume, vlax-invoke-method. The help file has very little information about the different methods, only that, using vlax-invoke-method I can invoke them.

Funny that I haven't looked into all of this before. Think of the time I could have saved.

In case anyone else, also unfamiliar with VL might read this, I'm speaking about doing this:

Code: [Select]
(vlax-dump-object  (vlax-ename->vla-object (car (entsel))) T)

to get the available properties and methods of a selected entity or this:

Code: [Select]
(vlax-dump-object  (vlax-ename->vla-object (car (nentsel))) T)

to get the available properties and methods of a selected sub-entity (like attributes or lines in a block).

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Visual LISP Question: Object Methods
« Reply #1 on: May 13, 2005, 12:25:52 PM »
Have you read the book?
http://dsxcad.com/
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Visual LISP Question: Object Methods
« Reply #2 on: May 13, 2005, 12:33:06 PM »
Quote from: nivuahc
Let's say, for example, I wanted to ScaleEntity using, I assume, vlax-invoke-method. The help file has very little information about the different methods, only that, using vlax-invoke-method I can invoke them.

Aha good question. Precisely why I had made the suggestion in another thread --

Quote
... get comfortable converting the vba help (methods and properties) to vla-equivalent ...

Look in the vba help for the method 'ScaleEntity' --



You have to learn how to convert the VBA code to the LISP equivalent. It's actually very easy. Rather than decribe it in a narrative, perhaps an example.

Visual BASIC --

Code: [Select]
Sub ScaleTest ( myObject as AcadEntity )

    Dim basePoint(0 to 2) as Double, _
        scaleFactor       as Double

    basePoint(0) = 0    
    basePoint(1) = 0    
    basePoint(2) = 0

    scaleFactor = 10.0

    myObject.ScaleEntity basePoint, scaleFactor

    ''  or

    Call myObject.ScaleEntity (basePoint, scaleFactor)
   
End Sub

LISP Equivalent --

Code: [Select]
(defun ScaleTest ( myObject )
    (if (vlax-method-applicable-p myObject 'ScaleEntity)
        (vla-ScaleEntity
            myObject    
            (vlax-3d-point '(0 0 0))    
            10.0
        )
    )    
)

Hope this helps.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Visual LISP Question: Object Methods
« Reply #3 on: May 13, 2005, 12:35:06 PM »
Also, the help file  for "ActiveX and VBA Reference" has all of the information you need.

Take your ScaleEntity example. Note that it has a (2) next to it, that means there will be 2 arguments required to be passed to it. From the help file we see that the 2 args are Basepoint and ScaleFactor, both of which are "input only" which means you must supply the value. So you would do something like this:
(vla-scaleentity obj (vlax-3d-point pt1) 2.0) to scale it by 2 with pt1 being the basepoint.

nivuahc

  • Guest
Visual LISP Question: Object Methods
« Reply #4 on: May 13, 2005, 12:44:38 PM »
Quote from: Se7en
Have you read the book?
http://dsxcad.com/


I will be now... Thanks John!

Michael/Jeff,

vla-ScaleEntity?

wha...

Okay, I'm gonna do some more reading.

Have I ever mentioned how much all of you guys rock? :dood:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Visual LISP Question: Object Methods
« Reply #5 on: May 13, 2005, 02:46:10 PM »
OK, let me get myself into trouble here. :)
I am a visual lisp nubee of sorts, so let's see if I can comment this code.
It is one of the best exercises I know of. Using it I learned a lot from Stig's code in the past.

Code: [Select]
(defun ScaleTest ( myObject )
  ;; first do a check to see if the ScaleEntity method can be applied to the object.
  ;;  this is a bit of error checking - use vlax-method-applicable-p
    (if (vlax-method-applicable-p myObject 'ScaleEntity)
        ;;  from the help ->  object.ScaleEntity BasePoint, ScaleFactor
        (vla-ScaleEntity   ; add vla-  to ScaleEntity
            myObject    ; object goes here out of order from the help file, this is the confusing part for most
            (vlax-3d-point '(0 0 0))   ; BasePoint, you have to convert the point list using (vlax-3d-point
            10.0  ;  no tricks here just the scale factor
        )
    )    
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

nivuahc

  • Guest
Visual LISP Question: Object Methods
« Reply #6 on: May 13, 2005, 05:08:58 PM »
That's how I understood it CAB

This VL stuff is purty nifty