TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: w64bit on July 01, 2017, 06:39:53 AM

Title: Dissasociate all hatches in model
Post by: w64bit on July 01, 2017, 06:39:53 AM
I am trying to disassociate all hatches in model with:
(if (setq hatch (ssget "_X" '((0 . "HATCH") (410 . "Model"))))(command "_HATCHEDIT" hatch "" "_DI"))
but it doesn't work.
Can anyone give me a hint to fix it?
Thank you.
Title: Re: Dissasociate all hatches in model
Post by: Lee Mac on July 01, 2017, 07:09:37 AM
Try the following:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:dehatch ( / sel qaf )
  2.     (if (setq sel (ssget "_X" '((0 . "HATCH") (410 . "Model"))))
  3.         (progn
  4.             (setq qaf (getvar 'qaflags))
  5.             (setvar 'qaflags 1)
  6.             (vl-cmdf "_.-hatchedit" sel "" "_DI")
  7.             (setvar 'qaflags qaf)
  8.         )
  9.     )
  10.     (princ)
  11. )
Title: Re: Dissasociate all hatches in model
Post by: w64bit on July 01, 2017, 07:39:03 AM
If I want to put it in a SCR file and to make it simpler, is it OK like this?

Code: [Select]
(if (setq sel (ssget "_X" '((0 . "HATCH") (410 . "Model"))))
(progn
(setvar 'qaflags 1)
(vl-cmdf "_.-hatchedit" sel "" "_DI")
(setvar 'qaflags 0)))
Title: Re: Dissasociate all hatches in model
Post by: w64bit on July 01, 2017, 08:25:24 AM
A simpler version for SCR file.

Code: [Select]
QAFLAGS 1
(if (setq sel (ssget "_X" '((0 . "HATCH") (410 . "Model"))))(command "_.-HATCHEDIT" sel "" "_DI"))
QAFLAGS 0

Thank you very much, Lee.
Title: Re: Dissasociate all hatches in model
Post by: Lee Mac on July 01, 2017, 08:26:29 AM
Save it as dehatch.lsp to an AutoCAD Support Path, then, in your Script:
Code: [Select]
(or (boundp 'c:dehatch) (load "dehatch.lsp" nil)) (if (boundp 'c:dehatch) (c:dehatch))