Jump to content

Visual lisp convert to Autolisp.


Dayananda

Recommended Posts

 (setq
    adoc (vla-get-activedocument (vlax-get-acad-object))
    blocks (vla-get-blocks adoc)
    lays (vla-get-layers adoc)
    color (acad_colordlg 256)
  )

Can someone to convert above code to AutoLisp.

Link to comment
Share on other sites

Here is a way to make a list of layers and blocks.

You probably don't need adoc (not sure, if you need it, show us in what context)

 

And I don't know why you need (acad_colordlg ).  Can you do without?  Or any suggestion how else to get this (example pick an object, return the color of its layer... )

 


(defun layers_table ( / res)
  (setq res (list))
  (while (setq lay (tblnext "LAYER" (not lay)))
    (setq res (append res (list (cdr (assoc 2 lay)))))
  )
  res
)

(defun blocks_table ( / res)
  (setq res (list))
  (while (setq blk (tblnext "BLOCK" (not blk)))
    (setq res (append res (list (cdr (assoc 2 blk)))))
  )
  res
)

(defun c:test ( / blocks lays)
  (setq
    ;; you probably don't need adoc
    blocks (blocks_table)
    lays (layers_table)
    ;; color (acad_colordlg 256)
  )
  (princ "\n -- BLOCKS -- \n")
  (princ blocks)
  (princ "\n -- LAYERS -- \n")
  (princ lays)
  (princ)
)

  • Thanks 1
Link to comment
Share on other sites

8 hours ago, Emmanuel Delay said:

Here is a way to make a list of layers and blocks.

You probably don't need adoc (not sure, if you need it, show us in what context)

Thanks . Your codes are good enough to start . 

  • Like 1
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...