Where to start (cui / menus / multiple selections)

Where to start (cui / menus / multiple selections)

Anonymous
Not applicable
1,293 Views
12 Replies
Message 1 of 13

Where to start (cui / menus / multiple selections)

Anonymous
Not applicable

I am currently working within the CUI and within this we have a menu created:

- Legacy

     - Image Tile Menus

          - General Block

               (Star symbol) Name

 

The (Star symbol) Name --> Allows a Macro and we are currently entering a block:

^C^Cinsunits;1;-INSERT Name;scale;$M=$(getvar,dimscale);\;

 

**Now this selection would be from the Pop-up and it would enter One block**

I have 6 blocks that I would like to be able to choose from otherwise I would to place in the menu block1, block2 etc.etc. and it would look horrible in the pop-up

 

My Questions or more to the point of what I am hoping to do is  invoke a command that lets me selection the orientation I would like to do

it would look like the AutoCAD Command ZOOM

ZOOM_SELECTION.JPG

but for All it would insert block "A"

Center --> Block "B"

etcetc

 

 

 

 

 

 

0 Likes
Accepted solutions (1)
1,294 Views
12 Replies
Replies (12)
Message 2 of 13

Jonathan3891
Advisor
Advisor
Accepted solution

To do that you will need a lisp file.

 

Replace "Alert" with the insert portion of the code.

 

(defun c:ttt (/ result)
  (initget 1 "Block1 Block2 Block3 Block4") ;1= no enter allowed
  (setq result (getkword (strcat "\nSelect Block [Block1/Block2/Block3/Block4]:")))
  (cond
    ((= result "Block1") (Block1))
    ((= result "Block2") (Block2))
    ((= result "Block3") (Block3))
    ((= result "Block4") (Block4))
    )
  )

(defun Block1 (/ )
(Alert "Block1")
  )

(defun Block2 (/ )
(Alert "Block2")
  )

(defun Block3 (/ )
(Alert "Block3")
  )

(defun Block4 (/ )
(Alert "Block4")
  )

Jonathan Norton
Blog | Linkedin
0 Likes
Message 3 of 13

Sea-Haven
Mentor
Mentor

You may be better with a custom menu, using old fashioned slides you can have visuals of your blocks you want to choose, a menu is created but its super simple and no real coding skills required. If number of blocks exceed it will auto multi page for you. Look at Hatches patterns select. 

 

Have  a look at screen shot

0 Likes
Message 4 of 13

Jonathan3891
Advisor
Advisor

How do you make those simple menus?


Jonathan Norton
Blog | Linkedin
0 Likes
Message 5 of 13

cadffm
Consultant
Consultant

That's an really old gui item, but works until today.

Read more about in your Help[F1] - Click!

Sebastian

0 Likes
Message 6 of 13

Sea-Haven
Mentor
Mentor

Its very easy to make a block type pick its built in so no coding just make a menu. This is a typical menu, you just have to know how the relevant sections work, making slides is easy, you can script the making of the slides so it will churn through multiple saved dwg blocks very fast.

 

***MENUGROUP=Alans

***POP20
**CADLIB
             [LIBRARY]
             [->Stddwgs]
             [TRENCH]$I=YYYSTDS.TRENCH $I=*
             [PIPES]$I=YYYSTDS.PIPES $I=*
             [PITS]$I=YYYSTDS.PITS $I=*
             [KERBS]$I=YYYSTDS.KERBS $I=*
             [ROADX]$I=YYYSTDS.ROADX $I=*
             [PAVEMENTS]$I=YYYYSTDS.PAVEMENT $I=*
             [MISC]$I=YYYSTDS.MISC $I=*
[<-]
 [->LISP1 A-B]
             [1/4 POINTS]^C^C(LOAD "1-4 POINTS")
             [Add 2 Level]^C^C(LOAD "add-to-levels")
             [Add-pits-drain]^C^C(LOAD"Add-pits-drain")
[<-]

***image
**TRENCH
[TRENCH]
[XXXSLD(CGG101,KERB)]^C^C(command "-open" "P:\\ACADSTDS\\CIVIL STANDARDS\\YYY101")
[XXXSLD(CGG102,NATURE)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/YYY102")

**PIPES
[PIPES]
[xxxxSLD(SD201,SUBSOIL)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/yyy201")
[xxxxSLD(SD202,FLUSHOUT)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/yyy202")
[xxxxSLD(SD203,CATCH)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/yyy203")

 

Message 7 of 13

Anonymous
Not applicable

Now that I have had a little bit of time to revisit this post,  this is more or less what I was after.

 

I am on the home stretch and hitting another wall - trial and error 

 

1.) Menu pull down(cui) - selects --> image/ grid

there is a MACRO -->op

can a macro load a lisp (the one you laid out) 🙂

 

^C^C(LOAD "CCL.lsp");CCL;

 

 

2.) current code (which doesn't work) get an error

Invalid option keyword. was trying a few things.. 

 

other wish list: insertion at user desired one click 

rotation=0 , scale 1 etc etc to get the block to just plop in :

 

(defun c:CCL(/ result)
(initget 1 "CL_LEFT_DYN_M CL_RIGHT_DYN_M") ;1= no enter allowed
(setq result (getkword (strcat "\nSelect CL Block Alignment: Left or Right [LEFT/RIGHT]:")))
(cond
((= result "LEFT") (CL_LEFT_DYN_M))
((= result "RIGHT") (CL_RIGHT_DYN_M))
((= result "L") (CL_LEFT_DYN_M))
((= result "R") (CL_RIGHT_DYN_M))
)
)


;(defun CL_LEFT_DYN_M (/ NAME)
; (setq NAME (strcat CL_LEFT_DYN_M))
; (setq LTSCA (getvar "dimscale"))
; (command "insert" NAME pause LTSCA "" PAUSE "")
😉


(DEFUN CL_LEFT_DYN_M (/ sc clay)
(setvar "cmdecho" 0)
(COMMAND "INSERT"
"CL_LEFT_DYN_M.dwg"
"S"
(SETQ sc (GETVAR "dimscale"))
(GETPOINT)
pause
) ;_ end of command

) ;_ end of defun

 

(DEFUN RIGHT (/ sc clay)
(setvar "cmdecho" 0)
(COMMAND "INSERT"
"CL_LEFT_DYN_M.dwg"
"S"
(SETQ sc (GETVAR "dimscale"))
(GETPOINT)
pause
) ;_ end of command

) ;_ end of defun

 

;(defun CL_RIGHT_DYN_M (/ )
;(Alert "CL_RIGHT_DYN_M")
; )

 

0 Likes
Message 8 of 13

Anonymous
Not applicable

(initget 1 "CL_LEFT_DYN_M CL_RIGHT_DYN_M") ;1= no enter allowed

 

 

CHANGE TO 

 

(initget 1 "LEFT RIGHT") ;1= no enter allowed

 

BINGO BANGO

0 Likes
Message 9 of 13

Jonathan3891
Advisor
Advisor

I've had issues using underscore's also with this format.


Jonathan Norton
Blog | Linkedin
0 Likes
Message 10 of 13

Jonathan3891
Advisor
Advisor

1. Yes you can have a macro load a lisp file

^C^C(if (not c:SomeCommand) (load "C:/your/path/here/LispFile.lsp" nil));SomeCommand;

2. This will do what you ask for inserting.

(command "insert" "C:/your/path/here/BlockName" "_Scale" 1 "_Rotate" 0 Pause)

You can use your drawing scale variable in place of the "1".


Jonathan Norton
Blog | Linkedin
0 Likes
Message 11 of 13

Sea-Haven
Mentor
Mentor

Use -insert as using command "insert" will pop open the dialog box -insert runs command line sequence note if you have attributes you will need to supply an answer.

 

(command "-insert" "C:/your/path/here/BlockName" (getpoint) 1 1 0)

 

If you have your blocks say in one directory add it to the support files then you can just use the block name and no path.

0 Likes
Message 12 of 13

cadffm
Consultant
Consultant

@Sea-Haven  schrieb:

Use -insert as using command "insert" will pop open the dialog box -insert runs command line sequence note if you have attributes you will need to supply an answer.


So alone, the statements are not correct, so I would like to complete.

 

>"note if you have attributes you will need to supply an answer."

Sometimes yes, sometimes no, depends on
a) how the attribute definitions are defined
b) What is the current setting of ATTREQ.

 

>"Use -insert as using command "insert" will pop open the dialog box"

This is not correct in such cases. Autocad detects the automation and automatically starts
"the commandline version for automation"

But I would also use the commandline version, even if it makes no technical difference.

It fits better with the meaning (I write down what is really going on) and
It is easier to understand, especially for beginners.

Why i wrote "the commandline version for automation"
It would be more important to explain that some commands started by hand are not the same command(version)s are,
that is executed by automations, thats why i wrote "the commandline version for automation".
-INSERT is a perfect sample, if i am right the default -INSERT command for automation comes from 2007,
the -INSERT command type in by hand comes from 2008 (Please do not beat if I'm wrong, better tell me why you disagree).

 

It sounds frightening to someone who does not know:

INSERT by hand, current Dialog/Palette version

INSERT via automation, old commandline-version

-INSERT via automation, old commandline-version

-INSERT by hand, current commandline-version

 

You can influence the version used, but my knowledge is limited. If someone can complete this information, please - only to:
Lisp, you can controle the command-version by Lisp function INITCOMMANDVERSION, for MenuMacros you can force the current version by using ^R

{ Automation = MenuMacro, Script.scr, Command/sendCommand via APIs }


Another sample, Explode
EXPLODE by hand starts the current version, EXPLODE in automation will start an old version which allows just to explode 1 object (in standard setting)
old command-version, just one object: ^C^C_.EXPLODE;_all;;
current command-version, multiple objects: ^C^C^R_.EXPLODE;_all;;

 

thanks for listening..

 

Sebastian

0 Likes
Message 13 of 13

Anonymous
Not applicable

OK - so I am on the last leg of this post.

I am looking at the insertion of the block into desired Drawings.

 

Issue: the blocks do not get entered at the correct size: (I am leaning towards the units/ and something not setup as it should)

 

1.) 2 Blocks

         - IMPERIAL  (TEXT @ 3/32)

         - MERTIC  (TEXT @ 2.5)

 

2.) For all imperial drawings  want to maintain text size and like on the Metric Size

 

I had the block units set to the units that the Block is millimeters for the metric and inches for the imperial.

I tested both insertions into a imperial and metric drawing .. than started playing with the unitless option ...

but regardless of the units - must maintain the correct text size.

 

what am I missing

 

0 Likes