Jump to content

Recommended Posts

Posted

Hello,

 

I found a script i would like to use but i have no idea how to run it, and i cannot find anything on the internet.

 

The script look like

 

Sub AllLayersToByLayer()
   Dim color As AcadAcCmColor
   Dim obj As AcadEntity
   
   Set color = New AcadAcCmColor
   With color
       .ColorMethod = acColorMethodByACI
       .ColorIndex = "256"
   End With
   
   For Each obj In ThisDrawing.ModelSpace
       obj.TrueColor = color
   Next obj
End Sub

 

My questions are:

What is this language?

how do i load this into autocad?

how do i execute this into a lisp file?

 

Please i need someone to explain me and assume i know close to nothing about programmation :)

Posted

Looks like VBA to me.

 

Is the SETBYLAYER command available to you?

Posted

This is VBA, and not autolisp.

If you know nothing about VBA, then loading this is not trivial.

Start here for more info: http://www.afralisp.net/visual-basic-for-applications/

 

This is a simple routine that could be written in lisp fairly easily, and it is a built in command in recent versions of AutoCAD. (Command: SETBYLAYER - available in R2008 and later)

Posted

Translation of your VBA to LISP:

 

(defun c:test nil (vl-load-com)
 (vlax-for object
   (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
   (vla-put-color object acbylayer)
 )
 (princ)
)

Posted

wow thank you very much, i prefer Lisp :)

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