Jump to content
theonlynelly

newbie needs help learning LISP

Recommended Posts

theonlynelly

Dear Cadtutor members :)

 

I am Nelly, new member of this forum and a very beginner autoCAD Civil 3D (2012 version) user. I am Indonesian who's now living in South Korea to pursue my degree. I got scholarship from a Korean's professor, so i'm doing this because of it :cry:

 

I need help about autolisp. I am new in this area, so i just googling it and found some reference on autolisp programming, but yet still don't understand about how to program with it and anything at all :oops:

 

I hope there's someone who can teach me in this area, because it's very important for my research study. Thank you in advance :)

 

 

Yours truly,

 

Nelly

Share this post


Link to post
Share on other sites
MSasu

I suggest you to start follow the tutorials from AfraLISP and when encounter issues just come back here and post your questions. Good luck on your learning.

 

Also, welcome to the Forum, Nelly!

 

Regards,

Mircea

Share this post


Link to post
Share on other sites
theonlynelly
I suggest you to start follow the tutorials from AfraLISP and when encounter issues just come back here and post your questions. Good luck on your learning.

 

Also, welcome to the Forum, Nelly!

 

Regards,

Mircea

 

Thank you for the kind answer :) I will try to learn from link you gave, wish i won't find any trouble :cry:

Share this post


Link to post
Share on other sites
theonlynelly

Dear MSasu,

 

Sorry for long time not coming to the venue :(

 

I have a problem..

 

From the bridge 3D model (produced by AutoCAD Civil 3D 2012), my professor told me to make a user interface from it. In the UI, for example if i click the beam of the bridge, it will pop-up the properties of the beam.

 

He doesn't told me how to do that, i just know that once he said that i have to use AutoLisp & SQL. As a newbie, i ask this to get enlightenment from you. I hope you can guide me to solve my problem.

 

Thank you in advance :notworthy:

Share this post


Link to post
Share on other sites
BIGAL

1 You need to read up on Entsel and DXF codes . Also using VL lisp makes some of this pulling apart entity information easier.

 

2 You can just print some answers 1 line after another.

 

3 Make a DCL that displays a more elaborate version of the answer.

 

(setq obj (entget (car (entsel "\nSelect object "))))
(setq Layname (strcat "Layer name is " (cdr (assoc 8 obj))))
(setq objtype (strcat "Object is a " (cdr (assoc 0 obj))) )

(princ objtype)

(princ layname)



Share this post


Link to post
Share on other sites
MSasu

One addition, the method proposed by @BIGALL will work perfectly for standard entities (lines, polylines, etc.). If those “beams” are entities that are specific to Civil 3D, then you may found that a deeper investigation is required. What need to do depend of how the extra information is stored in the associated list and linked dictionaries.

Share this post


Link to post
Share on other sites
theonlynelly
1 You need to read up on Entsel and DXF codes . Also using VL lisp makes some of this pulling apart entity information easier.

 

2 You can just print some answers 1 line after another.

 

3 Make a DCL that displays a more elaborate version of the answer.

 

 

(setq obj (entget (car (entsel "\nSelect object "))))
(setq Layname (strcat "Layer name is " (cdr (assoc 8 obj))))
(setq objtype (strcat "Object is a " (cdr (assoc 0 obj))) )

(princ objtype)

(princ layname)



 

Thank you for responding :)

 

I try your suggestion, and it results here:

_$ (setq obj (entget (car (entsel "\nselect object "))))

((-1 . ) (0 . "INSERT") (330 . ) (5 . "100E") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbBlockReference") (66 . 1) (2 . "Bridge_with_Attributes") (10 253.662 -556.123 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))

_$ (setq Layname (strcat "Layer name is " (cdr (assoc 8 obj))))

"Layer name is 0"

_$ (setq Layname (strcat "Layer name is " (cdr (assoc 0 obj))))

"Layer name is INSERT"

_$ (setq objtype (strcat "Object is a " (cdr (assoc 0 obj))))

"Object is a INSERT"

_$ (princ objtype)

Object is a INSERT"Object is a INSERT"

_$ (princ layname)

Layer name is INSERT"Layer name is INSERT"

 

I have no idea what's that about :cry:

Share this post


Link to post
Share on other sites
theonlynelly
One addition, the method proposed by @BIGALL will work perfectly for standard entities (lines, polylines, etc.). If those “beams” are entities that are specific to Civil 3D, then you may found that a deeper investigation is required. What need to do depend of how the extra information is stored in the associated list and linked dictionaries.

 

Honestly i don't have much time to learn Autolisp, i did it just when i have time :(

 

My professor ever gave me 4 Lisp file; which tittled are at.lsp, cls.lsp, sta.lsp, tag.lsp. Those contain are:

 

at.lsp

(defun c:at ( )

(entget (car (entsel)))

)

 

cls.lsp

(defun c:cls()

 

(setq ent (entsel))

(setq elist (entget (car ent)))

(setq name (cdr (assoc 3 elist)))

 

(setq filename "c:/tag-information/cls.txt")

(setq out (open filename "w"))

(write-line name out)

 

(close out)

)

 

sta.lsp

(defun c:sta()

 

(setq ent (entsel))

(setq elist (entget (car ent)))

(setq name (cdr (assoc 1 elist)))

 

(setq filename "c:/tag-information/sta.txt")

(setq out (open filename "w"))

(write-line name out)

 

(close out)

)

 

tag.lsp

(defun c:tag()

 

(setq ent (entsel))

(setq elist (entget (car ent)))

(setq name (cdr (assoc 2 elist)))

 

(setq filename "c:/tag-information/tag.txt")

(setq out (open filename "w"))

(write-line name out)

 

(close out)

 

But he didn't give me a hint. Can you explain to me what's that about? If you don't mind :)

Edited by theonlynelly

Share this post


Link to post
Share on other sites
BIGAL

A bit of an explanation but if you really dont know what entsel etc is about then you need to do some home work.

 

at.lsp
(defun c:at ( )   ; a lisp routine "at" called from command line or in another program 
(entget (car (entsel)))  ;(get the entity properties ready to be used (object name (select an object)))
)


(setq name (cdr (assoc 1 elist)))  ;(set variable name  (get 2nd part of answer (pull the variable with a DXF code of 1 out of the entity list)))

Edited by BIGAL

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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