I found this lisp: *Author Alan J. Thompson, 09.12.09*
;;; Offset inside of selected objects
;;; Alan J. Thompson, 09.12.09
(defun c:OffIn (/ #Dist #SSGet #Pline #Offset)
(vl-load-com)
(initget 6)
(cond
((and (setq #Dist (getdist "\nSpecify offset distance: "))
(setq #SSGet (ssget ":L" '((0 . "LINE,LWPOLYLINE,ARC"))))
) ;_ and
(if (zerop (getvar "peditaccept"))
(vl-cmdf "_.pedit" "_m" #SSGet "" "_y" "_j" "" "")
(vl-cmdf "_.pedit" "_m" #SSGet "" "_j" "" "")
) ;_ if
(if (not (vl-catch-all-error-p
(setq
#Offset
(vl-catch-all-apply
'vla-offset
(list (setq
#Pline (vlax-ename->vla-object (entlast))
) ;_ setq
(abs #Dist)
) ;_ list
) ;_ vl-catch-all-apply
) ;_ setq
) ;_ vl-catch-all-error-p
) ;_ not
(if (> (vla-get-area
(setq #Offset (car (vlax-safearray->list
(vlax-variant-value #Offset)
) ;_ vlax-safearray->list
) ;_ car
) ;_ setq
) ;_ vla-get-area
(vla-get-area #Pline)
) ;_ >
(progn
(vla-delete #Offset)
(if (not (vl-catch-all-error-p
(setq #Offset (vl-catch-all-apply
'vla-offset
(list #Pline (- (abs #Dist)))
) ;_ vl-catch-all-apply
) ;_ setq
) ;_ vl-catch-all-error-p
) ;_ not
(setq #Offset (car (vlax-safearray->list
(vlax-variant-value #Offset)
) ;_ vlax-safearray->list
) ;_ car
) ;_ setq
(setq #Offset nil)
) ;_ if
) ;_ progn
) ;_ if
(alert "Item cannot be offset.")
) ;_ if
(and #Pline (vla-explode #Pline))
)
) ;_ cond
(princ)
) ;_ defun
I added
(command "_move""_all""""""0,0,1e99""_move""_all""""""0,0,-1e99") - to move lines from 3d to 2d. This is not good because all drawings set Z 0
(command "_.-hatch" "P" "SOLID" "\\" "") - run solid hatch
(vla-delete #Pline) - delete pline
(vla-delete #Offset) - detele offset
(command "-purge" "z") - delete lines with 0 length. I don't know why those lines appear in the corners.
Changed lisp:
(defun c:OffIn (/ #Dist #SSGet #Pline #Offset)
(command "_move""_all""""""0,0,1e99""_move""_all""""""0,0,-1e99")
(vl-load-com)
(initget 6)
(cond
((and (setq #Dist (getdist "\nSpecify offset distance: "))
(setq #SSGet (ssget ":L" '((0 . "LINE,LWPOLYLINE,ARC"))))
) ;_ and
(if (zerop (getvar "peditaccept"))
(vl-cmdf "_.pedit" "_m" #SSGet "" "_y" "_j" "" "")
(vl-cmdf "_.pedit" "_m" #SSGet "" "_j" "" "")
) ;_ if
(if (not (vl-catch-all-error-p
(setq
#Offset
(vl-catch-all-apply
'vla-offset
(list (setq
#Pline (vlax-ename->vla-object (entlast))
) ;_ setq
(abs #Dist)
) ;_ list
) ;_ vl-catch-all-apply
) ;_ setq
) ;_ vl-catch-all-error-p
) ;_ not
(if (> (vla-get-area
(setq #Offset (car (vlax-safearray->list
(vlax-variant-value #Offset)
) ;_ vlax-safearray->list
) ;_ car
) ;_ setq
) ;_ vla-get-area
(vla-get-area #Pline)
) ;_ >
(progn
(vla-delete #Offset)
(if (not (vl-catch-all-error-p
(setq #Offset (vl-catch-all-apply
'vla-offset
(list #Pline (- (abs #Dist)))
) ;_ vl-catch-all-apply
) ;_ setq
) ;_ vl-catch-all-error-p
) ;_ not
(setq #Offset (car (vlax-safearray->list
(vlax-variant-value #Offset)
) ;_ vlax-safearray->list
) ;_ car
) ;_ setq
(setq #Offset nil)
) ;_ if
) ;_ progn
) ;_ if
(alert "Item cannot be offset.")
) ;_ if
(and #Pline (vla-explode #Pline))
(command "_.-hatch" "P" "SOLID" "\\" "")
(vla-delete #Pline)
(vla-delete #Offset)
(command "-purge" "z")
)
) ;_ cond
(princ)
) ;_ defun
Everything works properly BUT
after selecting an object I have to click inside the object again for it to appear solid hatch. Can it be set to be automatic and for multiple objects at once?
I attached gif example- offset hatch one object.
Thanks!