Jump to content

What is the right dxf code to fix this Autolisp routine ??


سبع الليل

Recommended Posts

بسم الله الرحمن الرحيم

الحمد لله وحده و الصلاة و السلام على من لا نبي بعده ،، و بعد

In the Name of Allah, the Most Beneficent, the Most Merciful

Dear kind members :

I have a question :

i wrote this routine ,,,

what i want is attaching steel bar info with the polyline entity ,, so when i call it i can get like any other property

here is the code

(defun c:bara ()
(setq n (getint "\nEnter number of bars"))
(setq d (getint "\nEnter diameter of bars"))
(regapp "barinfo")
(setq oldlist (entget (car (entsel))))
(setq barinfo '((-3 ("barinfo" (1005 . n) (1070 . d))))
(setq newlist (append oldlist barinfo))
(entmod newlist)
)

 

but this give me a bad dxf function because the code i enserted is wrong

what,s the right code which can i use it for this routine ,, or how can i fix it ??

i hope you can understand me ,, and sorry for my weak English

Edited by سبع الليل
Link to comment
Share on other sites

Try this code snip, change items to your suit

 
;build extension data 
(setq
xdata (list
(list -3 (list "barinfo"
(cons 1040 ps);real
(cons 1041 ln);distance
(cons 1000 hws);string 
(cons 1000 hwr);string 
;etc etc...
))
)
)
(setq xdlist (append elist xdata));append extension data to entity list
(entmod xdlist); setting data, modify entity list
(entupd en); update entity, optonal

Link to comment
Share on other sites

By constructing the list with quote instead of LIST function you were preventing the evaluation of the n and d variables. Also for integers must use the DXF code 1070. There was also an unbalansed paranthesis.

(defun c:bara ()
(setq n (getint "\nEnter number of bars"))
(setq d (getint "\nEnter diameter of bars"))
(regapp "barinfo")
(setq oldlist (entget (car (entsel))))
(setq barinfo [color=red](list (list[/color] -3 [color=red](list[/color] "barinfo" [color=red](cons 1070[/color] n) [color=red](cons[/color] 1070 d))))[color=red])[/color]
(setq newlist (append oldlist barinfo))
(entmod newlist)
)

 

Also, welcome to the Forum!

Link to comment
Share on other sites

Welcome to CADTutor.

 

The apostrophe will mark an expression as a literal (to be taken at face-value and not evaluated), hence the symbols 'n' & 'd' within your xData list will not be evaluated. For more information on the apostrophe, see my post here.

 

Furthermore, you are using DXF group 1005 (handle) to store an integer value, this group should be either group 1070 or group 1071 depending upon the size of your integer value. However, since you are prompting for a diameter, I would think the value should be a real (double) and using group 1040, or group 1041 (distance) rather than an integer.

Link to comment
Share on other sites

Mr Fixo

Mr Msasu

Mr Lee Mac

 

Really I thank you all very much ,,,

and i will not forget your favour ,,,

I understand now what is problem ,, and i fixed it ,, it will help me tooo much ,, what i was made in 5 hours now i can make in 5 minuites ...

I hope my english was strong enough to can express my thanks to you

U R really Generous ,, thank you all

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