Jump to content

pattern is different after matching HATCH


exceed

Recommended Posts

; hatch pattern unit edit, in place. metric <-> imperial - 2022.03.24 exceed
; If it doesn't work, run it twice.

(defun c:hps ( / acapp adoc sysvar gethatch gh_length gh_index gh_ename gh_obj gh_new_obj old_ps old_ptnm)
  (setq sysvar (getvar 'measurement))
  (setvar 'cmdecho 0)
  (LM:startundo (LM:acdoc))
  ;error control
    (defun *error* ( msg )
        (LM:endundo (LM:acdoc))
        (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
            (princ (strcat "\n Error: " msg))
        )
        (setvar 'cmdecho 1)
        (princ)
    )

  (cond 
    ((= sysvar 0) (progn (princ "\n Imperial(inch) -> Metric(mm)\n")
                          (setvar 'measurement 1) ))
    ((= sysvar 1) (progn (princ "\n Metric(mm) -> Imperial(inch)\n") 
                          (setvar 'measurement 0) ))
  )

  (setq gethatch '())
  (setq gh_length 0)

  (setq gethatch (ssget '((0 . "HATCH"))))
  (setq gh_length (sslength gethatch))
  (setq gh_index 0)
  
  (repeat gh_length
    (setq gh_ename (cdr (assoc -1 (entget (ssname gethatch gh_index)) ) ))
    (setq gh_obj (vlax-ename->vla-object gh_ename))
    (setq old_ptnm (vla-get-patternname gh_obj))
    (setq old_ps (vla-get-patternscale gh_obj))
    (vla-put-patternname gh_obj "SOLID")
    (vla-put-patternscale gh_obj (+ old_ps 1))
    (vla-put-patternscale gh_obj old_ps)
    (vla-put-patternname gh_obj old_ptnm)
    (setq gh_index (+ gh_index 1))
  )

  (vla-Regen (LM:acdoc) :vlax-true)     
  (LM:endundo (LM:acdoc))
  (setvar 'cmdecho 1)
  (princ)
)
  
  
  
;; Active Document  -  Lee Mac
;; Returns the VLA Active Document Object

(defun LM:acdoc nil
    (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
    (LM:acdoc)
)


;; Start Undo  -  Lee Mac
;; Opens an Undo Group.

(defun LM:startundo ( doc )
    (LM:endundo doc)
    (vla-startundomark doc)
)

;; End Undo  -  Lee Mac
;; Closes an Undo Group.

(defun LM:endundo ( doc )
    (while (= 8 (logand 8 (getvar 'undoctl)))
        (vla-endundomark doc)
    )
)

 

 

Applied in case of problems with acad.pat (imperial) and acadiso.pat (metric).

 

Select the hatch with errors and run HPS.

 

step

1. because current MATCH is wrong, so change the MEASUREMENT value from 0 to 1 and from 1 to 0.

2. After saving the current pattern, change the pattern to solid. This is to prevent it from disappearing *during the routine when the scale is changed. 

3. To apply the current MEASUREMENT to the hatch, add 1 and subtract 1 from the pattern scale.

4. To show that the pattern has changed, run Regen.

* - Due to the nature of hatches, hatches may disappear if run over an area that is too small for the Result

 

If this works normally without lisp : MATCH -> if incorrect -> enter MEASUREMENT -> enter 0 or 1 -> MATCH again

In other words, this lisp has made the short road to long, for my practice.

 

Edited by exceed
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...