Jump to content

Recommended Posts

Posted (edited)

Hello. I have a set of items and I need to create a block. I use the "command", but I delete items when creating the block. I want to leave them on the screen as normal elements.

What I can do to ensure they survive the elements of drawing???

Regards

 

(command "_-block" nombre_bloque punto_insercion conjunto_elementos "")

Edited by SLW210
Code Tags!!
Posted

Either create a block from a copy of the objects, or insert the newly created block at the base point.

 

Some food for thought:

 

[color=GREEN];; Objects to Block  -  Lee Mac[/color]
[color=GREEN];; Converts a selection of objects to a block reference.[/color]
[color=GREEN];; Limited to non-attributed blocks.[/color]

([color=BLUE]defun[/color] c:obj2blk ( [color=BLUE]/[/color] e i l n p s x )
   ([color=BLUE]if[/color]
       ([color=BLUE]and[/color]
           ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] [color=MAROON]"_:L"[/color] '((-4 . [color=MAROON]"<NOT"[/color]) (0 . [color=MAROON]"ATTDEF,VIEWPORT"[/color]) (-4 . [color=MAROON]"NOT>"[/color]))))
           ([color=BLUE]progn[/color]
               ([color=BLUE]while[/color]
                   ([color=BLUE]not[/color]
                       ([color=BLUE]or[/color] ([color=BLUE]=[/color] [color=MAROON]""[/color] ([color=BLUE]setq[/color] n ([color=BLUE]getstring[/color] [color=BLUE]t[/color] [color=MAROON]"\nSpecify Block Name <Anonymous>: "[/color])))
                           ([color=BLUE]and[/color]
                               ([color=BLUE]snvalid[/color] n)
                               ([color=BLUE]null[/color] ([color=BLUE]tblsearch[/color] [color=MAROON]"BLOCK"[/color] n))
                           )
                       )
                   )
                   ([color=BLUE]princ[/color] [color=MAROON]"\nBlock name invalid or already exists."[/color])
               )
               ([color=BLUE]if[/color] ([color=BLUE]=[/color] [color=MAROON]""[/color] n)
                   ([color=BLUE]setq[/color] n [color=MAROON]"*U"[/color])
               )
               ([color=BLUE]setq[/color] p ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify Base Point: "[/color]))
           )
       )
       ([color=BLUE]progn[/color]
           ([color=BLUE]entmake[/color]
               ([color=BLUE]list[/color]
                  '(0 . [color=MAROON]"BLOCK"[/color])
                   ([color=BLUE]cons[/color] 10 ([color=BLUE]trans[/color] p 1 0))
                   ([color=BLUE]cons[/color] 02 n)
                   ([color=BLUE]cons[/color] 70 ([color=BLUE]if[/color] ([color=BLUE]wcmatch[/color] n [color=MAROON]"`**"[/color]) 1 0))
               )
           )
           ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s))
               ([color=BLUE]entmake[/color] ([color=BLUE]entget[/color] ([color=BLUE]setq[/color] e ([color=BLUE]ssname[/color] s ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i))))))
               ([color=BLUE]if[/color] ([color=BLUE]=[/color] 1 ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 66 ([color=BLUE]entget[/color] e))))
                   ([color=BLUE]progn[/color]
                       ([color=BLUE]setq[/color] x ([color=BLUE]entnext[/color] e)
                             l ([color=BLUE]entget[/color]  x)
                       )
                       ([color=BLUE]while[/color] ([color=BLUE]/=[/color] [color=MAROON]"SEQEND"[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 0 l)))
                           ([color=BLUE]entmake[/color] l)
                           ([color=BLUE]setq[/color] x ([color=BLUE]entnext[/color] x)
                                 l ([color=BLUE]entget[/color]  x)
                           )
                       )
                       ([color=BLUE]entmake[/color] l)
                   )
               )
               ([color=BLUE]entdel[/color] e)
           )
           ([color=BLUE]if[/color] ([color=BLUE]setq[/color] n ([color=BLUE]entmake[/color] '((0 . [color=MAROON]"ENDBLK"[/color]))))
               ([color=BLUE]entmake[/color]
                   ([color=BLUE]list[/color]
                      '(0 . [color=MAROON]"INSERT"[/color])
                       ([color=BLUE]cons[/color] 02 n)
                       ([color=BLUE]cons[/color] 10 ([color=BLUE]trans[/color] p 1 0))
                   )
               )
           )
       )
   )
   ([color=BLUE]princ[/color])
)

Posted

Hello Lee Mac. Very very awesome.

Thanks, thanks........thanks.

Posted

Welcome to the forum. :)

Looks like Lee has already got you covered,

so you are in excellent hands. :beer:

I have never used Autocad 2006, so am not sure if you have this option or not.

In more recent versions when using the BLOCK or WBLOCK commands there is an option called RETAIN

which will create the block, and leave the defining objects in their original state in the drawing.

wblock retain option.JPG

Posted

There's always the _.OOPS command. -David

Posted

Hi Dadgad. The problem is that this option does not know how to put it in code

(command "_-block" nombre_bloque punto_insercion conjunto_elementos "")

Perhaps some system variable.

 

Hi Lee Mac. For starters, I've known the existence of the command "snvalid".

jejejeje. Gradually you come away. Greetings to all.

Posted

Hello again. Lee, your routine is great, but there is a problem. It retains the elements, but insert a block. Should I explode the block?. Can we do anything to retain the original elements???

Posted

Did you try the OOPS command?

 


(command "_-block" nombre_bloque punto_insercion conjunto_elementos ""
        "_.OOPS")

 

-David

Posted

Sorry David. I did not understand the previous answer. Now I understand. I did not know that option: oops.

It's fine. Greetings and thanks for everything.

Posted
Hello again. Lee, your routine is great, but there is a problem. It retains the elements, but insert a block. Should I explode the block?. Can we do anything to retain the original elements???

 

Yes, to retain the original objects, simply comment the line:

 

([color=BLUE]entdel[/color] e)

If you also do not want the resultant block to be inserted, change:

 

(if (setq n (entmake '((0 . "ENDBLK"))))
   (entmake
       (list
          '(0 . "INSERT")
           (cons 02 n)
           (cons 10 (trans p 1 0))
       )
   )
)

to:

 

([color=BLUE]entmake[/color] '((0 . [color=MAROON]"ENDBLK"[/color])))

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