Jump to content

some help understanding nomenclature for objects, entities, Visual LISP, ActiveX


cagorskij

Recommended Posts

Apologies if my questions are tedious, i'm trying to learn as much as i can on my own before asking, but when it comes to disambiguating objects, entities and activex objects i'm still struggling to completely wrap my head around it.
i guess i'm just looking for some simple explanation. ive never been great at understanding these sorts of layered disambiguations whether it be networking layers or this ~_~


i've read a little but it's hard for me to search when i'm not sure which words to even use haha ^^;
this old post, this less old post & this onethis autocad 2023 help page, & this autocad 2024 page.

as i understand it,

  • cad has entities and objects, which are distinguised by whether they have a graphical representation or not (respectively)
    • does this mean all entities are objects?
  • vl stands for visual lisp?
  • vlax objects are higher level Visual LISP representations of regular cad objects and entities
  • to access the vlax functions it is required to load the library first then retrieve or generate(?) the vlax representation the objects
  • enames are the identifiers of vanilla lisp entities which are basically older versions of vlax objects (from here, but im not sure i interpreted correctly)
    • that is why there are functions like vlax-ename->vla-object, so that you can run with the same variable rather than having 2 i guess?
      • i dont understand the use of entity name (ename) here instead of object name. i thought enames were a pre-vl thing
  • the vla-get-<property> and vla-put-<property> are effectively equivalent to the vlax versions?
  • object methods are just complicated gets or puts, using more arguments or modifying more properties.
Link to comment
Share on other sites

You may want to do a little research on object-oriented programming (OOP). Once you understand inheritance, abstraction, encapsulation, and polymorphism, it's easier to see how the pieces of an OOP system fit together.

 

For instance, an AutoCAD object is more like a class, while an entity is more like an instance of a class. The class defines how the entity can behave, but the instance tells you how a particular entity does behave.

 

Visual LISP is a dialect of AutoLISP that works in an Integrated Development Environment (IDE). It's supposed to make programming easier. Visual LISP objects aren't higher level, they're the same objects in a different space. The libraries are necessary to run code in that space. Visual LISP, in effect, adds a layer of abstraction so that you don't get stuck in the weeds of AutoLISP.

 

Commands that start with vla- are part of Visual LISP. Commands that start with vlax- are part of the ActiveX system, which allows you to access other types of documents, such as Word or Excel. ActiveX commands are at once more generic and more powerful. Unfortunately, you can only use ActiveX with Windows.

 

If you want to retrieve the layer of an object, you can do it either way, but notice the difference:
 

(vla-get-layer 'obj)

(vlax-get-property 'obj Layer)

 

With the first command, you get the layer of an object. With the second one, you can get any property of that object, even if the property isn't related to AutoCAD. You can use either one, depending on how you feel about context, readability, and consistency.

  • Like 2
Link to comment
Share on other sites

Thank you Danielm103 for the visualization & CyberAngel for the very helpful explanation. With both I'm feeling a lot more comfortable with my understanding now :)

  • Like 1
Link to comment
Share on other sites

Here are the two lisp I use to dump data.

 

should update to use (ssget "_+.:E:S") instead of entsel this means you can select things before you run the command. always bugs me I will have the thing selected that I want to dump and then type the command and still have to select it again.

 

;;----------------------------------------------------------------------------;;
;; Dump All Visual Lisp Methods and Properties for Selected Entity
;; RO = Read Only and cant be changed with lisp
(defun C:VDumpIt (/ ent)
  (while (setq ent (car (entsel "\nSelect Entity to Dump")))
    (vlax-Dump-Object (vlax-Ename->Vla-Object ent) t)
  )
  (princ)
)
;;----------------------------------------------------------------------------;;
;; Dump all DXF Group Data             
(defun C:DumpIt (/ ent)
  (while (setq ent (car (entsel "\nSelect Entity to Dump")))
    (mapcar 'print (entget ent '( "*")))
  )
  (princ)
)

 

 

  • Like 1
Link to comment
Share on other sites

Another example of how you can write 1 function in different ways.

 

(vlax-get obj 'Layer)

; opposite

(vlax-put obj 'Layer "Text")

 

I use this for entget object checking I just type it or I have a shortcut. It is a real short just pick an object, there is no prompt.

 

(entget (car (entsel)))

 

In the developers help there are pretty pictures where they talk about classes and objects .


https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-FC6FC3E3-ED3E-4E4D-9766-8E4D037241A5

 

A great document you should be able to find "The_Visual_LISP_Developers_Bible"

 

 

Edited by BIGAL
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...