Jump to content

Recommended Posts

Posted

Hi,

I have snippet as below as part of the lisp code

 

(setq obj1 (vlax-ename->vla-object (car (entsel "\nPick object 1"))))

 

Could you please assist to get layername of the obj1.

I have tried

(setq VLA_OBJ_LAYER (vla-get-layer obj1))

   (setq VLA_ACT_DOC (vla-get-ActiveDocument (vlax-get-Acad-Object)))

   (setq LAYERNAME (vla-Item (vla-get-Layers VLA_ACT_DOC) VLA_OBJ_LAYER))

 

But it run to error.

Thanks

Posted
(setq LAYERNAME (vla-get-layer obj1))

Posted

Perfect..Thank you very much for the help Marko Ribar.

Posted

FWIW Your attempt should be written as:

 

(setq LAYERNAME (vla-get-layer obj1))

(setq VLA_ACT_DOC (vla-get-ActiveDocument (vlax-get-Acad-Object)))

(setq VLA_OBJ_LAYER (vla-Item (vla-get-Layers VLA_ACT_DOC) LAYERNAME))

 

So you just reverse the symbolnames of "VLA_OBJ_LAYER" and "LAYERNAME" to refer to their (correct) values.

Posted (edited)

You will find this very handy it will show the properties and a lot of them you can get at with a VLA-GET-xxxxxxx obj you can also do the opposite and use VLA-PUT-xxxxxx obj to change values.

 

;;;===================================================================; 
;;; DumpIt                                                            ; 
;;;-------------------------------------------------------------------; 
;;; Dump all methods and properties for selected objects              ; 
;;;===================================================================; 
(defun C:DumpIt ( / ent) 
 (while (setq ent (entsel)) 
   (vlax-Dump-Object 
     (vlax-Ename->Vla-Object (car ent)) 
  T ) 
 ) 
 (princ) 
)

 

;   EndPoint = (513.775 345.565 0.0)
;   Layer = "DEFAULT"
;   Length (RO) = 250.296
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Material = "ByLayer"
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 42
;   ObjectName (RO) = "AcDbLine"
;   OwnerID (RO) = 43
;   PlotStyleName = "ByLayer"
;   StartPoint = (263.479 345.565 0.0)
;   Thickness = 0.0

Edited by BIGAL
Posted
You will find this very handy it will show the properties and a lot of them you can get at with a VLA-GET-xxxxxxx obj you can also do the opposite and use VLA-PUT-xxxxxx obj to change values.

 

;;;===================================================================; 
;;; DumpIt                                                            ; 
;;;-------------------------------------------------------------------; 
;;; Dump all methods and properties for selected objects              ; 
;;;===================================================================; 
(defun C:DumpIt ( / ent) 
 (while (setq ent (entsel)) 
   (vlax-Dump-Object 
     (vlax-Ename->Vla-Object (car ent)) 
   ) 
 ) 
 (princ) 
)

 

;   EndPoint = (513.775 345.565 0.0)
;   Layer = "DEFAULT"
;   Length (RO) = 250.296
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Material = "ByLayer"
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 42
;   ObjectName (RO) = "AcDbLine"
;   OwnerID (RO) = 43
;   PlotStyleName = "ByLayer"
;   StartPoint = (263.479 345.565 0.0)
;   Thickness = 0.0

To get the methods, you need to include the 'T' for vlax-dump-object like so:

(vlax-dump-object (vlax-ename->vla-object (car ent)) t)

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...