Jump to content

Recommended Posts

Posted

Dear all,

 

I'm quite new to LISP and I've been looking around the forum a lot for an answer to my problem but couldn't find it, therefore I ask your help!

 

I am trying to write a code that does these following actions:

 

1 - user types in command line (WOOD in this case)

2 - user selects an object (closed polyline or rectangle or whatever)

3 - lisp creates associative hatch with defined pattern and scale (var FILL and SC - since I want to do different materials with the same code, the pattern should be an independent variable) WITHOUT asking for internal point AND on the same layer as the selected object.

 

This is what I've done up to now but it asks for the internal point (actually if you select the internal point it won't hatch :?) and creates it in current layer...

 

(defun c:WOOD (/)
(setq FILL "ANSI31")
(setq cmdold (getvar "CMDECHO"))
(setq oldlayer (getvar "CLAYER"))
(setvar "CMDECHO" 0)
(setq SC "5")
(setq ent (entsel))
(command "._-bhatch" "_P" FILL SC "0.0" "_S" ent "")
(setvar "CMDECHO" 1)
(setvar "CLAYER" oldlayer)
(princ)
)

Can anybody help me?

Posted

This ... ?

 

(defun c:Test (/ fill sc ss i sn)
 ;;; Tharwat 16. March. 2012 ;;;
 (setq fill "ANSI31"
       sc   5.
 )
 (if (setq ss (ssget '((0 . "LWPOLYLINE,POLYLINE"))))
   (repeat (setq i (sslength ss))
     (if (vlax-curve-isclosed (setq sn (ssname ss (setq i (1- i)))))
       (progn
         (command "_.-hatch" "_P" fill sc "0.0" "_S" sn "" "")
         (entmod (subst (assoc 8 (entget sn))
                        (assoc 8 (entget (entlast)))
                        (entget (entlast))
                 )
         )
       )
     )
   )
   (princ)
 )
 (princ)
)

Posted

Great! It works perfectly, thanks!

 

I had some problems at the beginning because I forgot to put in (vl-load-com), and I had to change to ._-bhatch otherwise it was giving an error...

Posted
Great! It works perfectly, thanks!

 

I had some problems at the beginning because I forgot to put in (vl-load-com), and I had to change to ._-bhatch otherwise it was giving an error...

 

You're welcome

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...