TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: like_citrus on November 20, 2020, 02:46:35 AM

Title: Insert block - variable size
Post by: like_citrus on November 20, 2020, 02:46:35 AM
I have a set of blocks for different size bolts which I insert from a pull down menu. The method is described below.
I wanted to have a way that I could input what length the bolt should be.
Can this be done?
It doesn't sound easy as most lines/arcs stay the same but some change in length.


METHOD
A file exists for each block (M6.dwg, M8.dwg, M10.dwg, etc).
These CAD files, a script file and menu file (see code below) are all placed in one folder.
Then the script file is run from AutoCAD to generate the menu.
Then go to menu, choose a block and it's inserted.


SCRIPT FILE (.scr extension)
Code: [Select]
(if (and (not (findfile "STEEL.mnu"))
(findfile "C:\\Pull down menu\\POP12 Steel\\STEEL.mnu")
)
(setenv "ACAD" (strcat (getenv "ACAD") "C:\\Pull down menu\\POP12 Steel"))
)
(command "._MENULOAD" "STEEL.mnu")
(menucmd "P12=+STEEL.CTOPopSTEEL")

MENU FILE (.mnu extension)
Code: [Select]
***MENUGROUP=STRUCTURAL_STEEL
***POP12
**CTOPopSTEEL

              [Steel]

              [->Bolts]
                 [M6]^C^C(BlockInsert "Bolts_M6");scale;1;
                 [M8]^C^C(BlockInsert "Bolts_M8");scale;1;
                 [M10]^C^C(BlockInsert "Bolts_M10");scale;1;
                 [M12]^C^C(BlockInsert "Bolts_M12");scale;1;
                 [M16]^C^C(BlockInsert "Bolts_M16");scale;1;
                 [M20]^C^C(BlockInsert "Bolts_M20");scale;1;
                 [M24]^C^C(BlockInsert "Bolts_M24");scale;1;
                 [M30]^C^C(BlockInsert "Bolts_M30");scale;1;
                 [<-M36]^C^C(BlockInsert "Bolts_M36");scale;1;
              [--]

Title: Re: Insert block - variable size
Post by: CAB on November 20, 2020, 08:30:02 AM
I think you would need dynamic blocks of the bolts or to create then on the fly from data tables.
Title: Re: Insert block - variable size
Post by: like_citrus on November 20, 2020, 08:20:42 PM
OK thanks, it looks like this is the way to go then.
Title: Re: Insert block - variable size
Post by: BIGAL on November 21, 2020, 03:04:07 AM
have a look at this

Title: Re: Insert block - variable size
Post by: like_citrus on November 21, 2020, 03:09:48 AM
That's what I was looking for. Thanks BIGAL.
Title: Re: Insert block - variable size
Post by: BIGAL on November 21, 2020, 05:05:39 PM
Can not take the credit was not created by me, very useful.