Jump to content

Search the Community

Showing results for tags 'addselected'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • CADTutor
    • News, Announcements & FAQ
    • Feedback
  • AutoCAD
    • AutoCAD Beginners' Area
    • AutoCAD 2D Drafting, Object Properties & Interface
    • AutoCAD Drawing Management & Output
    • AutoCAD 3D Modelling & Rendering
    • AutoCAD Vertical Products
    • AutoCAD LT
    • CAD Management
    • AutoCAD Bugs, Error Messages & Quirks
    • AutoCAD General
    • AutoCAD Blogs
  • AutoCAD Customization
    • The CUI, Hatches, Linetypes, Scripts & Macros
    • AutoLISP, Visual LISP & DCL
    • .NET, ObjectARX & VBA
    • Application Beta Testing
    • Application Archive
  • Other Autodesk Products
    • Autodesk 3ds Max
    • Autodesk Revit
    • Autodesk Inventor
    • Autodesk Software General
  • Other CAD Products
    • BricsCAD
    • SketchUp
    • Rhino
    • SolidWorks
    • MicroStation
    • Design Software
    • Catch All
  • Resources
    • Tutorials & Tips'n'Tricks
    • AutoCAD Museum
    • Blocks, Images, Models & Materials
    • Useful Links
  • Community
    • Introduce Yourself
    • Showcase
    • Work In Progress
    • Jobs & Training
    • Chat
    • Competitions

Categories

  • Programs and Scripts
  • 2D AutoCAD Blocks
  • 3D AutoCAD Blocks
  • Images
    • Backgrounds

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Found 1 result

  1. 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
×
×
  • Create New...