Jump to content

Selecting Entities after implementing commands


Tharwat

Recommended Posts

Hi

I made the following Lisp But to select the four Circles within the same time is the problem that I do not know ..... how??

 

We might be able to use after each circle(setq 1stCircle (ssget "_l")) But I thought it is not the proper way ........ any idea????

(defun c:ww (/ width height cover incover inheight UpDia UpRad a b c d e f g h Dist1 Dist2 Dist3 Dist4 1cir 2cir 3cir 4cir )
(if (< (setq width(getdist"\nSpecify beam Width min <100> mm:")) 100)
   (progn
       (alert "Width of beam must be minimum 100")
       (c:ww)))
 (if (< (setq height (getdist"\nSpecify beam Height min <100> mm:")) 100)
     (progn
   (alert "Height of Beam must be minimum 100")
   (exit))
          (princ))
  (initget (+ 1 2 4))
 (setq cover (getint"\nSpecify cover:")
incover (- width (* cover 2))
inheight(- height (* cover 2)))
 (initget (+ 1 2 4))
 (setq UpDia(getint"\nSpecify Upper Bars Diameter:")
UpRad (/ UpDia 2))						  
 (setq a (getpoint"\nSpecify Point:"))
 	(setq oldsnap (getvar "osmode"))
 	(setq oldortho (getvar "orthomode"))
 	(setq newsnap (setvar "osmode" 0))
 	(setq newortho (setvar "orthomode" 0))
 (setq b (polar a (dtr 0.0) width)
       c (polar b (dtr -90.0) height)
       d (polar c (dtr -180.0) width)
       e (list(+ (car a) cover)(- (cadr a) cover))
f (polar e (dtr 0.0) incover)
g (polar f (dtr -90.0) inheight)
h (polar g (dtr -180.0) incover))
   (command "_pline" a "_w" 0 0 b c d "_c" "")
   (command "_pline" e f g h "_c" "")
 (setq pl (ssget "_l"))
 (setvar "filletrad" uprad)
 (command "_fillet"  "_p" pl)
  (setvar "osmode" oldsnap)
(setvar "orthomode" oldortho)
 (setq Dist1 (distance a b)
       Dist2 (distance b c)
       Dist3 (distance d c)
       Dist4 (distance a d)
     )
(setq 1cir (list(+ (car a)(/ Dist1 2))
	(cadr a))
     2cir (list (car b)
	 (- (cadr b)(/ Dist2 2)))
     3cir (list (+ (car d)(/ Dist3 2))
	 (cadr d))
     4cir (list (car a)
	 (- (cadr a )(/ Dist4 2)))
     )
 (command "_circle" 1cir UpRad ; <---How to select this circle to implement hatch pattern at it ?
   "_circle" 2cir UpRad ; <---How to select this circle to implement hatch pattern at it ?
   "_circle" 3cir UpRad ; <---How to select this circle to implement hatch pattern at it ?
   "_circle" 4cir UpRad ; <---How to select this circle to implement hatch pattern at it ?
  	   )
 (command  "_-hatch" "_p" "solid" "_s" (ssget "_l") ""  "") ; <---- This Hatch would be implemented only at the last one
 (princ "Made by Tharwat")
 (princ)
 )
(defun DTR (ang)(* pi (/ ang 180.0)))

 

Tharwat

Link to comment
Share on other sites

You could get them by executing entlast after each one, but why not just use entmakex and have them in a list, or did you want a SelectionSet?

 

(setq lst (mapcar
           (function
             (lambda (pt)
               (entmakex (list '(0 . "CIRCLE") (cons 10 pt) (cons 40 UpRad)))
             )
           )
           (list 1cir 2cir 3cir 4cir)
         )
)

Link to comment
Share on other sites

Call every command separatelly

(setq sset (ssadd));<--create empty selection set
;;then add entity to selectin set
(command "_circle" 1cir UpRad)
(ssadd (entlast) sset):<-- add newly created circle in selection set
(command "_circle" 2cir UpRad)
(ssadd (entlast) sset):<-- add next one
;;etc etc

Now you have the populated selection set

 

~'J'~

Link to comment
Share on other sites

SelectionSet:

 

(setq ss (ssadd))
(foreach pt (list 1cir 2cir 3cir 4cir)
 (ssadd (entmakex (list '(0 . "CIRCLE") (cons 10 pt) (cons 40 UpRad))) ss)
)

Link to comment
Share on other sites

You could get them by executing entlast after each one, but why not just use entmakex and have them in a list, or did you want a SelectionSet?

Thanks to you mr Alanjt.

 

I included your code in my routine although that I haven't used it before, so anyway it is done , But how to hatch them by Hatch command since the

'setg 1st' is holding the Circles. ... Take a look please.

(setq 1cir (list(+ (car a)(/ Dist1 2))(cadr a))
     2cir (list (car b)(- (cadr b)(/ Dist2 2)))
     3cir (list (+ (car d)(/ Dist3 2))(cadr d))
     4cir (list (car a)(- (cadr a )(/ Dist4 2)))
     ) 
 (setq lst
      (mapcar (function
                (lambda (pt)
                  (entmakex (list '(0 . "CIRCLE") (cons 10 pt) (cons 40 UpRad)))
                )
              )
              (list 1cir 2cir 3cir 4cir)
      )
)
 (command  "_-hatch" "_p" "solid" "_s" [color="Red"]1st[/color] ""  "") ; <---- This Hatch would be implemented only at the last one

Link to comment
Share on other sites

Hatch will only accept a SelectionSet or EName. If you want one hatch object, I'd use the SelectionSet example I posted, if you want individual hatches, I'd step through the list with foreach and hatch each EName.

Link to comment
Share on other sites

SelectionSet:

 

(setq ss (ssadd))
(foreach pt (list 1cir 2cir 3cir 4cir)
 (ssadd (entmakex (list '(0 . "CIRCLE") (cons 10 pt) (cons 40 UpRad))) ss)
)

 

Yes That's it it is great mr.Alan

 

Your first codes were smooth in Lisp implementation But it was new and a little bit hard to control of the selections

 

Best Regards

Tharwat

Link to comment
Share on other sites

Call every command separatelly

(setq sset (ssadd));<--create empty selection set
;;then add entity to selectin set
(command "_circle" 1cir UpRad)
(ssadd (entlast) sset):<-- add newly created circle in selection set
(command "_circle" 2cir UpRad)
(ssadd (entlast) sset):<-- add next one
;;etc etc

Now you have the populated selection set

 

~'J'~

Thanks a lot Mr.fixo

that was also helpful, and don't you agree that following 'entlast' after each

command could be a matter of over loading ??

 

I have used your technique but with 'ssget "_l" ' if would noticed that in the

routine ....... so I do appreciate your participation with it so much.

 

Best Regards

 

Tharwat

Link to comment
Share on other sites

Call every command separatelly

(setq sset ([color="Red"]ssadd[/color]));<--create empty selection set
;;then add entity to selectin set
(command "_circle" 1cir UpRad)
(ssadd (entlast) sset):<-- add newly created circle in selection set
(command "_circle" 2cir UpRad)
(ssadd (entlast) sset):<-- add next one
;;etc etc

Now you have the populated selection set

~'J'~

Hello

The function ssadd did not make the selection of the first circle ... ?

Can you please tell me why ?

 

Thanking you

 

Tharwat

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