Author Topic: Adding a Help Option to a routine  (Read 1119 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Adding a Help Option to a routine
« on: August 05, 2021, 08:00:53 AM »
I am trying to figure out within the command line, to give the user an option to activate a help file.
Within the Ribbon CUI, I have a pulldown with the command on top and then the help command on the bottom.

I.E. (Command: Select entity on a layer:) to (Command: Select entity on a layer: or Help)


Code: [Select]
(defun C:DDEMO () ;;Displays Demolition Layers
(command "-layer" "Set" "0" "")
(command "-layer" "Thaw" "*DEMO*" "")
(princ)
); defun

or

(defun c:lay (/ e ) ;;Highlight All Objects on Selected Layer
 (if (setq e (nentsel "Select entity on a layer: "))
   (sssetfirst nil (ssget "_X" (list (cons 8 (cdr (assoc 8 (entget (car e))))))))
  )
 (princ)
)



It is just an idea but I thought I would like to get some ideas on how this could work.

Thanks again guys
Civil3D 2020

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: Adding a Help Option to a routine
« Reply #1 on: August 06, 2021, 03:05:07 AM »
If you select nothing ie pick blank screen you can check pick was nil so could pop a slide, using vslide, or even open a txt file, pdf etc. There is some use of initget that may be helpful, not my area of expertise.

(Command: Select entity on a layer: Enter for Help)
A man who never made a mistake never made anything

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Adding a Help Option to a routine
« Reply #2 on: August 11, 2021, 07:32:40 AM »
I came close and found this to help with the command menu. Its just a condition, but i think it might work.

Code: [Select]
(defun C:Test ()
(initget "Demo Help")
(setq uAns
 (cond ((getkword "\nDisplay Demolition Layers [Demo/Help] <Demo> : "))
       ("Demo")))

  (cond ((eq uAns "Demo")
       (alert "Turn on Demo Layers.")
       (C:DDEMO)

     )
     ((eq uAns "Help")
       (alert "Run Help Command.")
  )
)
(princ))


(defun C:DDEMO () ;;Displays Demolition Layers
(command "-layer" "Set" "0" "")
(command "-layer" "Thaw" "*DEMO*" "")
(princ)
); defun
Civil3D 2020

framednlv

  • Newt
  • Posts: 64
Re: Adding a Help Option to a routine
« Reply #3 on: August 11, 2021, 09:51:26 AM »
I use something like this to open documentation I've written:
Code: [Select]
(if  (setq MyHelp$ (findfile "MY Help File.txt"))
  (startapp "explorer.exe" MyHelp$)(Print "No help found"))

JohnK

  • Administrator
  • Seagull
  • Posts: 10604
Re: Adding a Help Option to a routine
« Reply #4 on: August 11, 2021, 10:45:52 AM »
For larger help topics/situations I've used this in production because it allowed me to just modify the help file(s) instead of modifying the actual lisp file(s). -e.g. changing contact information.

I even used this in company/department/location notifications situations. -e.g. "NOTIFICATION: Save your DRAWINGS."

Code - Auto/Visual Lisp: [Select]
  1. (defun HelpDisplay (help-file )
  2.    ;; this function demonstrates how to read and display formatted text
  3.    ;; on the screen from a text file.
  4.   (princ "\n")
  5.   (repeat 75 (princ "="))
  6.   (
  7.    (lambda ( f / )
  8.      (defun pars (s f)
  9.        ;; by: ElpanovEvgeniy
  10.        (if s
  11.          (cons s
  12.                (pars (read-line f) f)
  13.                ) ;_ cons
  14.          (close f)
  15.          ) ;_ if
  16.        )
  17.      (princ "\n")
  18.      (mapcar '(lambda (x) (write-line x)) (pars (read-line f) f))
  19.      (princ)
  20.      )
  21.    (open help-file "R")
  22.    )
  23.   (repeat 75 (princ "="))
  24.   (textscr)
  25.   (princ)
  26.   )


SampleHelp.txt

Code: [Select]
## BRIEF ##

A brief (one paragraph) description here.

## DESCRIPTION ##

A long project description here.

Love to eat them mousies,
Mousies what I love to eat.
Bite they little heads off,
Nibble on they tiny feet.
-- Kliban


It has been said that we stand on one another's shoulders.  If
this is the case, then programmers stand on one another's toes, and
software engineers dig each other's graves.
-- Unknown


(HelpDisplay "C:\\Temp\\SampleHelp.txt")
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Adding a Help Option to a routine
« Reply #5 on: August 11, 2021, 11:46:42 AM »
Great Ideas guys! Never thought of it, in that way...
Civil3D 2020