woodman78 Posted March 1, 2017 Author Posted March 1, 2017 Is the above code complete? I don't see where you've defined "outpline"... Yes BKT. The code is complete. I haven't defined the variable but when I do I get an error. If I define it in the main function it fails to run the lisp. Quote
BIGAL Posted March 2, 2017 Posted March 2, 2017 Woodman78 Can you post a before and after dwg, I know what I posted is close it does not hatch automatically and needs a couple of extra automations but it is still quick. Version 3 would work differently working out the points for the hatch boundry so only need a starting line, width and gap. Roy_043 yeah trim hatch but it appears to be fussy about pick point but great idea. Quote
Roy_043 Posted March 2, 2017 Posted March 2, 2017 Roy_043 yeah trim hatch but it appears to be fussy about pick point but great idea.That is not what I mean. There is no need to trim the hatch as you can quite easily create a correct hatch. Simple code using a command call: (setq enm (car (entsel))) (command "_.-bhatch" "_properties" "_user" 45 ; Angle in degrees. 10 ; Line spacing. "_no" ; Cross hatch. "_select" enm "" "" ) A more sophisticated version would store, change and restore several HP* variables (HPNAME, HPANGLE, HPSPACE and HPDOUBLE), or use Visual Lisp functions. Quote
woodman78 Posted March 2, 2017 Author Posted March 2, 2017 Bigal, I have included the dwg with the hatch block inside it. I think that mine is more straight forward in that the boundary needs to be drawn anyway to form the lanes on the road. All mine involves then is roughly drawing a line up the middle and selecting that and the boundary as part of the lisp. No need to select points. Hatch Test.dwg Quote
BKT Posted March 2, 2017 Posted March 2, 2017 Without knowing when or where you're defining "outpline" it's hard to test your code. Running it as posted on the dwg you supplied doesn't show much. As BIGAL suggested, it would help to see an image of what you're trying to achieve. Can you just post a screenshot of a before and after? Quote
Roy_043 Posted March 3, 2017 Posted March 3, 2017 An extended, but still simple, version of the HATCH solution: (defun c:Test ( / *error* ang enm lstEnt org spc varLst varOld wid) (defun *error* (msg) (if (and varLst varOld) (mapcar 'setvar varLst varOld) ) (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\nError: " msg)) ) ) (setq varLst '( cmdecho hpname hpang hpspace hpdouble hporigin ) ) (setq varOld (mapcar 'getvar varLst)) ; Store variables. (if (and (setq enm (car (entsel "\nSelect boundary entity: "))) (setq ang (getangle "\nLine angle: ")) (setq spc (getdist "\nLine spacing: ")) (setq wid (getdist "\nLine width: ")) (setq org (getpoint "\nOrgin point: ")) ) (progn (setvar 'cmdecho 0) (setvar 'hpname "_USER") (setvar 'hpang ang) (setvar 'hpspace spc) (setvar 'hpdouble 0) (setvar 'hporigin (list (car org) (cadr org))) (setq lstEnt (entlast)) (command "_.-bhatch" "_select" enm "" "" ) (if (not (equal (entlast) lstEnt)) (progn (command "_.explode" (entlast)) (command "_.pedit" "_multiple" "_previous" "") (if (zerop (getvar 'peditaccept)) (command "_yes")) (command "_width" wid "") ; End of _.pedit. ) ) ) ) (mapcar 'setvar varLst varOld) ; Restore variables. (princ) ) Quote
Recommended Posts
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.