Search the Community
Showing results for tags 'hatch associativity'.
-
Hatch_Off.lsp - Script for HATCHING from existing hatch with no hatch dialog.
3dwannab posted a topic in AutoLISP, Visual LISP & DCL
Hi, Ever annoyed about having to open the hatch dialog to get inherent props from an existing hatch and then AutoCAD seems to think it fine for the hatch to be non associative too!!! Here is a script I wrote and wanted to share. It simply uses the addselected command to hatch your selected objects even though they might be non associative, this will ensure associative hatches for life........ It works with every hatch type you can throw at it (Anno and backgrounds too) while retaining ALL the exact same properties. I need to get it so it'll add the annotation scales but the script will set the flag for it if the source hatch is annotative. PLEASE LET ME NOW WHAT YOU THINK OR DON'T THINK ABOUT IT. ;; FUNCTION SYNTAX Hatch_Off or HOFF ;; ABOUT / NOTES ;; ABOUT / NOTES ;; - Hatches using ADDSELECTED command method, no more Hatch UI (EVER) to pick an existing HATCH. ;; - Automatically changes the HPASSOC variable to 1 then sets it back, ;; upon error or exiting the command. ;; - First pick the HATCH you want then, select your LWPOLYLINES, CIRCLES or ELLIPSES to HATCH. ;; This routine is made to only select closed LWPOLYLINES. An easy way to identify them. ;; You can run a script called PSIMPLE to fix you entire drawing in one go. See here >>> http://www.theswamp.org/index.php?topic=19865.msg244786#msg244786 ;; - If you want un-associative HATCH for some reason change '(setvar 'hpassoc 1)' to '0'. ;; - Automatically selects the newly created HATCH/es. ;; - Sends draworder of HATCH behind selected objects. ;; FULL CODE ;; --------------------------=={ Hatch_Off }==---------------------------- ;; ----------------------------------------------------------------------- ;; AUTHOR & ADDITIONAL CODE ;; Author: 3dwannab, Copyright © 2018. ;; Error functions: LeeMac Help pages. www.lee-mac.com. ;; ABOUT / NOTES ;; - Hatches using ADDSELECTED command method, no more Hatch UI (EVER) to pick an existing HATCH. ;; - Automatically changes the HPASSOC variable to 1 then sets it back, ;; upon error or exiting the command. ;; - First pick the HATCH you want then, select your LWPOLYLINES, CIRCLES or ELLIPSES to HATCH. ;; This routine is made to only select closed LWPOLYLINES. An easy way to identify them. ;; You can run a script called PSIMPLE to fix you entire drawing in one go. See here >>> http://www.theswamp.org/index.php?topic=19865.msg244786#msg244786 ;; - If you want un-associative HATCH for some reason change '(setvar 'hpassoc 1)' to '0'. ;; - Automatically selects the newly created HATCH/es. ;; - Sends draworder of HATCH behind selected objects. ;; FUNCTION SYNTAX ;; Short-cut HOFF ;; Long-cut Hatch_Off ;; VERSION DATE INFO ;; Version 1.0 26-07-2018 Initial release. ;; Version 1.01 27-07-2018 var_hatch_bkgcolouradded to set the hatch background colour to none so that the addselected command doesn't use that instead of the original one picked. ;; TO DO LIST ;; Change the polylines to the current boundary attributes of selected hatch boundary. ;; Put all of the annotative scales to the newly created hatch. ;; If a hatch exists on the selected polylines then delete them and hatch with new. ;; Check if it works in different UCS modes. (NOT SURE) ;; ----------------------------------------------------------------------- ;; ---------------------=={ Hatch_Off START }==--------------------------- (defun c:---LOAD_HATCH_OFF (/) (LOAD "Hatch_Off") (c:HOFF)) (defun c:HOFF () (c:Hatch_Off)) (defun c:Hatch_Off ( / *error* ent_1 ent_1_vla ent_1_data sel_me ss_1 tmp var_cmde var_hatch_ass var_hatch_bkgcolour var_os ) (setq *error* LM:error) (LM:startundo) (setq var_cmde (getvar "cmdecho")) (setq var_hatch_anno (getvar "hpannotative")) (setq var_hatch_ass (getvar "hpassoc")) (setq var_hatch_bkgcolour (getvar "hpbackgroundcolor")) (setq var_os (getvar "osmode")) (setvar 'cmdecho 0) (setvar 'osmode 0) (setvar 'hpbackgroundcolor ".") (while (not (and (setq ent_1 (car (entsel "\nPlease select a HATCH to copy.\n: ------------------------------ :\n\nThen select any closed LWPOLYLINE's, CIRCLE's or ELLIPSE's.\n")) ent_1_data (if ent_1 (entget ent_1)) ) (= (cdr (assoc 0 ent_1_data)) "HATCH") (sssetfirst nil) (setq ent_1_vla (vlax-ename->vla-object ent_1)) (progn (setq ent_last (entlast) sel_me (ssadd) ) (while (setq tmp (entnext ent_last)) (setq ent_last tmp)) (princ "\nNow select your objects to be HOFF'ified !\n") (setq ss_1 (ssget '( (-4 . "<OR") (-4 . "<AND") (0 . "LWPOLYLINE") (70 . 1) (-4 . "AND>") (-4 . "<AND") (0 . "CIRCLE,ELLIPSE") (-4 . "AND>") (-4 . "OR>") ))) (if (IsAnno-p (vlax-ename->vla-object ent_1)) (setvar 'hpannotative 1) ) (setvar 'hpassoc 1) (if ss_1 (progn (command "_.addselected" "_non" ent_1 "_S" ss_1 "" "" ) (command "._draworder" (entlast) "" "_U" ss_1 "") (while (setq ent_last (entnext ent_last)) (ssadd ent_last sel_me) ) (sssetfirst nil sel_me) (princ (strcat "\nYou've been HOFF'd with < "(itoa (sslength ss_1)) (if (> (sslength ss_1) 1) " > objects" " object") " hatched.\n")) ) ) )(princ) ) ) ) (*error* nil)(princ) )(princ) ;; ----------------------------------------------------------------------- ;; ----------------------=={ Functions START }==-------------------------- (vl-load-com) (defun IsAnno-p (ent / exd ano) (vl-load-com) (and (eq (vla-get-HasExtensionDictionary ent) :vlax-true) (setq exd (vla-GetExtensionDictionary ent) exd (vla-item exd "AcDbContextDataManager") ano (vla-item exd "ACDB_ANNOTATIONSCALES") ) (not (zerop (vla-get-Count ano))) ) ) (defun LM:error (errmsg) (and acDoc (vla-EndUndoMark acDoc)) (and errmsg (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*")) (princ (strcat "\n<< Error: " errmsg " >>\n")) ) (setvar 'cmdecho var_cmde) (setvar 'hpassoc var_hatch_ass) (setvar 'osmode var_os) (setvar 'hpannotative var_hatch_anno) (setvar 'hpbackgroundcolor var_hatch_bkgcolour) (princ (strcat "\nNo HOFF for you today !\n")) ) (princ) (defun LM:startundo () (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc)) ) (princ) ;; ----------------------------------------------------------------------- ;; -----------------------=={ Functions END }==-- ------------------------ (princ "\nHatch_Off loaded | Version 1.0 | by 3dwannab.\n") (princ "\nType \"Hatch_Off\" OR \"HOFF\" to run.\n") (princ) ;; ----------------------------------------------------------------------- ;; ----------------------=={ Hatch_Off END }==---------------------------- ;; EOL- 3 replies
-
- hatch
- addselected
-
(and 1 more)
Tagged with:
-
How to Hide Hatch boundary?
cad_cow posted a topic in AutoCAD 2D Drafting, Object Properties & Interface
I wish to hide my associative hatch boundaries. Is this possible to do as a permanent rule? I have seen that you can apparently put them on a different layer then turn them off. Does anyone have a quick trick for what i am trying to achieve? I used the selectsimliar command but it chose all polylines (which i guess is what a hatch boundary is?) Any ideas, or is this going to be a tedious job each time i wish to hide them....?- 12 replies
-
- hatch associativity
- frames
-
(and 2 more)
Tagged with:
-
I want to remove all data labels from a drawing and I want hatches to fill the gaps. All hatches are created as associative fills. When I remove data labels using a Quick Select or Select Similar command only a few neighboring hatch areas are updated. As for the remaining gaps from labels persist. Now I am removing them one by one. Initial state: After removing labels: Any ideas?