Jump to content

Recommended Posts

Posted

Can anyone help with creating a lisp which can create block with attributes from selecting mtext and objects. also keeping the mtext value as it is and in same size and shape, with option to change justification.

test.dwg

Posted
17 hours ago, SLW210 said:

showing error when I tried Command: TTB
Specify block name [HPO-Boundary , HPO-Setout , DP-Boundary , DP-Connection] < DP-Boundary > : HPO-S
; error: bad argument type: lselsetp nil.

 

in my drawing it should convert selected text into Attributed block. I have placed 3 types of cases in Dwg and in lisp it should have button for selecting justification and it will keep text size and style as it is in the text before block.

Posted

There are a few LISPs in that thread, the one you picked was someone trying to make alterations.

 

Did you try any of the others?

Posted
17 hours ago, SLW210 said:

There are a few LISPs in that thread, the one you picked was someone trying to make alterations.

 

Did you try any of the others?

I had tried all, in that thread and got some errors. As it was written for that specific case.

Posted

Answer 1, the best answer would be a block with a circle a line and then attributes, say up to 4 attributes but they have nothing in them the prompt is blank, then you can select mtext etc and it will fill in attributes. The way to go is maybe a dynamic block not a leader, then can rotate the joining line to circle point.

 

Answer 2 If only want as shown then make a new block that has line pointing to centre of circle with attributes. Can read existing and replace. So make new block and post again. If want say 4 directions then need 4 blocks.

Posted (edited)
18 hours ago, BIGAL said:

Answer 1, the best answer would be a block with a circle a line and then attributes, say up to 4 attributes but they have nothing in them the prompt is blank, then you can select mtext etc and it will fill in attributes. The way to go is maybe a dynamic block not a leader, then can rotate the joining line to circle point.

 

Answer 2 If only want as shown then make a new block that has line pointing to centre of circle with attributes. Can read existing and replace. So make new block and post again. If want say 4 directions then need 4 blocks.

isn't lisp can't make directly mtext and lines or elements into attribute blocks by selectng them?  

 

found below lisp which can convert text into attributes

(defun c:txt2att (/ ss i en ed)
(while (not ss)
(princ "\nSelect TEXT to Convert to ATTDEF: ")
(setq ss (ssget (list (cons 0 "TEXT")
(if (getvar "CTAB")
(cons 410 (getvar "CTAB"))
(cons 67 (- 1 (getvar "TILEMODE"))))))))

(setq i (sslength ss))
(while (not (minusp (setq i (1- i))))
(setq en (ssname ss i)
ed (entget en))
(if (wcmatch (cdr (assoc 1 ed)) "* *")
(alert "\nString Contains Spaces - Try Again...")
(progn
(entmake (list (cons 0 "ATTDEF")
(assoc 8 ed)
(assoc 10 ed)
(assoc 11 ed)
(assoc 7 ed)
(assoc 40 ed)
(assoc 41 ed)
(assoc 50 ed)
(assoc 51 ed)
(cons 70 0)
(assoc 71 ed)
(assoc 72 ed)
(cons 74 (cdr (assoc 73 ed)))
(assoc 210 ed)
(cons 1 "")
(cons 2 (cdr (assoc 1 ed)))
(cons 3 (cdr (assoc 1 ed)))
(if (assoc 6 ed) (assoc 6 ed)'(6 . "BYLAYER"))
(if (assoc 39 ed) (assoc 39 ed)'(39 . 0))
(if (assoc 62 ed) (assoc 62 ed)'(62 . 256))))
(entdel en))))
(redraw)
(prin1))
(c:txt2att)

 

in my drawing there is already mtext which in either one line(street name type) or 2 line(for Lot number) and some has hexagonal inside number(bubble marking) and additional text(SOW). what i want is to click them one by one and they will be converted to block and the text inside the selection will be attributed type.

Edited by SLW210
Added Code Tags!!
Posted

Please use Code Tags for codes. (the <> in the editor toolbar)

Posted

If you must make the blocks then why not just make all of them using bedit. I can see the need for 4 directions, Top, bottom, left, right. And then also 1 attribute 2 attribute 3 attribute and so on. Much easier make them than keep asking for another version please. You juts start with "Block1-R" Bsave, move attribute and line work, bsave Block1-R and so on  4 blocks made. Just add 2nd attribute repeat bsave 4 times. keep adding Attributes and using Bsave should be say 15 minutes work. 

 

When you pick text or mtext it would know use b1 b2 b3 b4, then ask is it T,B,L, or R. If block does not exist it goes and gets the blocks from an existing dwg. 

 

My Multi radio buttons.lsp will give you the 4 direction choices. It would need 3 lines of code then another 5 for the cond answer. You may not need it as the pick mtext would work out direction.

Posted (edited)

Hi @smitaranjan,

 

Try this LISP which i made and use "DYNAMIC_BLOCK.dwg" to insert a BLOCK with ATTRIBUTES into the drawing. The MAX number of TEXT or MTEXT that can be placed within each ATTRIBUTE is 1 (total number of ATTRIBUTE is 4). Also, if your selection set of TEXT or MTEXT is greater than 4, you will receive a message in the command line with a list of values from the selection set whose list length is greater than 4. Inside TBA.lsp you will find other information about how lisp works. Try to save a "DYNAMIC_BLOCK.dwg" and TBA.lsp in folder anywhere on disk partition, it will be much easier. See a picture which hold a descriptions for "grips".

 

Feel free to provide comments about TBA.lsp.

 

Best regards.

 

 

DYNAMIC_BLOCK_DESCRIPTION.JPG

TBA.lsp DYNAMIC_BLOCK.dwg

Edited by Saxlle
  • Like 1
Posted
6 hours ago, Saxlle said:

Hi @smitaranjan,

 

Try this LISP which i made and use "DYNAMIC_BLOCK.dwg" to insert a BLOCK with ATTRIBUTES into the drawing. The MAX number of TEXT or MTEXT that can be placed within each ATTRIBUTE is 1 (total number of ATTRIBUTE is 4). Also, if your selection set of TEXT or MTEXT is greater than 4, you will receive a message in the command line with a list of values from the selection set whose list length is greater than 4. Inside TBA.lsp you will find other information about how lisp works. Try to save a "DYNAMIC_BLOCK.dwg" and TBA.lsp in folder anywhere on disk partition, it will be much easier. See a picture which hold a descriptions for "grips".

 

Feel free to provide comments about TBA.lsp.

 

Best regards.

DYNAMIC_BLOCK.dwg 78.04 kB · 1 download TBA.lsp 20.25 kB · 2 downloads

 

DYNAMIC_BLOCK_DESCRIPTION.JPG

@Saxlle its useful but in my case it will take longer time than manual placing by copy and paste into a block and in some cases i have without table and all. 

Posted
23 hours ago, BIGAL said:

If you must make the blocks then why not just make all of them using bedit. I can see the need for 4 directions, Top, bottom, left, right. And then also 1 attribute 2 attribute 3 attribute and so on. Much easier make them than keep asking for another version please. You juts start with "Block1-R" Bsave, move attribute and line work, bsave Block1-R and so on  4 blocks made. Just add 2nd attribute repeat bsave 4 times. keep adding Attributes and using Bsave should be say 15 minutes work. 

 

When you pick text or mtext it would know use b1 b2 b3 b4, then ask is it T,B,L, or R. If block does not exist it goes and gets the blocks from an existing dwg. 

 

My Multi radio buttons.lsp will give you the 4 direction choices. It would need 3 lines of code then another 5 for the cond answer. You may not need it as the pick mtext would work out direction.

for new files, i have already blocks which can work. but for old files which will be replaced by the blocks taking more time to copy paste existing mtexts. That's why needed a lisp which will help in making the work easier.

Posted

Again read what I said if you have the blocks made then it's easy to work out which block to use or just make a 4 attribute block and leave values blank if no text or text

Posted

@smitaranjan

 

This is how TBA lisp works. See the attached video. You don't need to manually copy and paste TEXT or MTEXT inside of block! After selection set is finished you just need to pick a point where to insert block one by one. If this fit for your needs, use it.

 

Best regards.

  • Thanks 2
Posted

Your welcome. 🙂  

I hope it serves you. 

 

Best regards. 

  • Thanks 1
Posted
On 9/24/2024 at 12:52 PM, Saxlle said:

@smitaranjan

 

This is how TBA lisp works. See the attached video. You don't need to manually copy and paste TEXT or MTEXT inside of block! After selection set is finished you just need to pick a point where to insert block one by one. If this fit for your needs, use it.

 

Best regards.

can you try to modify code and block to fit in the below requirements

TEST2.dwg

Posted
4 hours ago, smitaranjan said:

can you try to modify code and block to fit in the below requirements

TEST2.dwg 51.58 kB · 1 download

Please make a clear dwg file, because in "TEST2" I don't understand what you want (there are polylines, block, mtext, ...). Do you want to make another block to be "dynamic" or use the one I made but can adapt to your needs? Also, provide one example file where you want to use lisp and block (that would be much easier).

 

Best regards.

Posted
14 hours ago, Saxlle said:

Please make a clear dwg file, because in "TEST2" I don't understand what you want (there are polylines, block, mtext, ...). Do you want to make another block to be "dynamic" or use the one I made but can adapt to your needs? Also, provide one example file where you want to use lisp and block (that would be much easier).

 

Best regards.

I have attached again and placed the requirements. Yes these 2 blocks to be dynamic. may be you can create option to choose between these 2 blocks in required situation.

TEST3.dwg

Posted (edited)

@smitaranjan

 

According to your request, i made a two blocks which are you going to use and made a TBA_smitaranjan.lsp file. Also, see the attached video how it works (notice the text in leader which i put and you need to do before run TBA). Sorry for the poor quality of the video, due to the maximum total size that can be uploaded to the forum or download it from this link (better quality of the video) --> https://we.tl/t-IQvmdqDNYQ.

 

Best regards.

 

 

 

TBA_smitaranjan.lsp DYNAMIC_BLOCK_1.dwg DYNAMIC_BLOCK_2.dwg

Edited by Saxlle
  • Like 1

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