Jump to content

Recommended Posts

Posted (edited)

i want to call multiple functional codes in a single/main lsp file and want to load that main lsp file to the autocad drawing. Now the requirement here is im trying to get the key words(using initget) to appear in the command bar or to get displayed as a drop down in autocad so that user is provided with all the names of functional codes, over which selecting any of them should actually run the respective code
here im attaching a trial autolisp code that's helpful to understand how i wanna display the functional codes embedded in mail lsp file:
 

(defun c:trial()

  (setq jeldwin 1.116 ;Jeldwin has a 3.116" Window Frame

    brown 0.1875 ;Brown has a 2 3/16" Window Frame

      newmar 1 ;Newmar has a 3" Window Frame.

      pollard 1.5 ;Pollard has a 3.5" Window Frame

  )

  (if (null Global:WinMan)

    (setq Global:WinMan "B")

    )

  (initget "Brown Jeldwin Newmar Pollard")

    (if (setq win (getkword (strcat "\nWhich window manufacturer [Brown/JeldWin/Newmar/Pollard]<" Global:WinMan "> : ")))

    (setq Global:WinMan win)

    )

)


any ideas for..how to build the logarithm upon this requirement to perform both loading the multiple functional codes and get their keywords to run it successfully

feel free also to reply to my personal mail: venkatmedisetty6699@gmail.com

Edited by SLW210
Code Tags!
Posted

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

Posted

BigAl has a multivals code - see the downloads, when he is awake (different time zones) he might remind us the link - it up there in down loads if you want a popup / DCL box to select the functional code.

 

This uses the command line. The basics of this one is a list with all the detail (MyFunctions).. here index name, page size and function.. which creates the initget and keyword options.. doing in one list makes updating easier in a few years time when you forget how it all works. Use (assoc....) function to choose the detail you want to use once the name is selected. 

 

I've just added c:test as the function to run when a name is selected - so this will loop and loop

 

 

Now sure if this is something useful?

 

 

(defun c:test ( / MyFunctions MyInitGet n )
;;Sub Functions
  ;;list to string nth ite in nested lists
  (defun lst->str (MyList MyNth Del / )
    (setq MyResult "")
    (foreach n MyFunctions
      (setq MyResult (strcat MyResult (nth MyNth n) Del))
    ) ; end foreach  
  )

;;List of options, option options
;;cons list: index ('value' 'function-inc c:' )
;;All strings.
  (setq MyFunctions (list
    (cons "Jeldwin" '("1.116" "c:test") )
    (cons "Brown" '("0.1875" "c:test") )
    (cons "Newmar" '("1" "c:test") )
    (cons "Pollard" '("1.5" "c:test") )
  )) ; end setq end list

;; get input
  (initget (lst->str MyFunctions 0 " "))
  (setq win (getkword (strcat "\nWhich window manufacturer " (lst->str MyFunctions 0 "/") "<Jeldwin> : ")))


(setq MyPageSize (nth 1 (assoc win MyFunctions)))
(princ MyPageSize)
    
;;run a function from the chosen option.
;;Function from options list, 'nth 2'
  (eval (read (strcat "(" (nth 2 (assoc win MyFunctions)) ")")))

)

 

Posted (edited)

As steven suggested I replaced Initget with a library DCl the one to use is Multi Radio Buttons.lsp, you just save it to a support directory so it can autoload. Yes there is Multi getvals, Multi toggles, plus a couple more.

 

 

image.png.f541c15bce2fe3a7c8e03de3e93bc64b.png

 

(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(setq ans (ah:butts 1 "V"   '("Please pick" jeldwin" Brown" "Newmar" "Pollard" )))

Multi radio buttons.lsp

Edited by BIGAL
  • 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...