Originally Posted by
jpcadconsulting347236
Hey gang,
I'm trying to write a lisp routine that does the following:
- Closes the ribbon
- Issues the hatch command (using the dialog box)
- Restores the ribbon after closing the hatch dialog
I almost have it here, but it
does not restore the ribbon:
Code:
(defun C:qh ()
(command "ribbonclose")
(initdia) ; allow dialog
(command "_.hatch")
(princ)
)
(command "ribbon")
The Ribbon is not being re-enabled as the call to do so is outside of your routine's scope.
Instead, consider this quick adaptation, which first checks to see if the Ribbon is enabled, restoring the Ribbon only as needed, and will also handle any errors:
Code:
(defun c:QuickHatch (/ *error* on)
(defun *error* (msg)
(if on (command "._ribbon"))
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
)
(princ)
)
(if (setq on (= 1 (getvar 'ribbonstate)))
(command "._ribbonclose")
)
(initdia)
(command "._hatch")
(*error* nil)
)
Now, for the record... The quickest way I know of hatching one or more closed polylines is to simply select them on screen and right click:
... Those who may be interested in adding this custom functionality should use the 'Autodesk Exchange' link in my signature.
Cheers