Jump to content

Help many circle center layout rectangle and rotate rectangle


Rain0923

Recommended Posts

Help needed a lisp!!

1.There are many circle center and base on circle center layout rectangle(rectangle

can keyin size).

2.Then base on circle center rotate all rectangle for any angle.

Pls Help!!

Link to comment
Share on other sites

sample.pdf

Huh ? No idea just a responce for the now 48 people who has looked at this post. If you don't explain clearly no one will answer.

 

Sorry!I attach a file for my explain .

Link to comment
Share on other sites

Ok a very simple lisp task so maybe its time to have a go

 

A suggestion use VL-lisp as it more descriptive to what your retrieving for this project

 

; copy this next line to your command line and pick circle you will see the entity detail names use a vla-get-"entityname"
(vlax-Dump-Object (vlax-Ename->Vla-Object (car (entsel "pick circle"))))

: need this line at start
(vl-load-com)
1 select circle get radius and center point see dump detail above
2 draw a 4 sided pline (setq pt2 (polar pt1 0 rad)) join pt1 pt2 pt3 c
3 rotate the square (command "rotate" "L" note the drag switch
4 all done ! congrats you have done a lisp

Edited by BIGAL
Link to comment
Share on other sites

Ok a very simple lisp task so maybe its time to have a go

 

A suggestion use VL-lisp as it more descriptive to what your retrieving for this project

 

; copy this next line to your command line and pick circle you will see the entity detail names use a vla-get-"entityname"
(vlax-Dump-Object (vlax-Ename->Vla-Object (car (entsel "pick circle"))))

: need this line at start
(vl-load-com)
1 select circle get radius and center point see dump detail above
2 draw a 4 sided pline (setq pt2 (polar pt1 0 rad)) join pt1 pt2 pt3 c
3 rotate the square (command "rotate" "L" note the /drag switch
4 all done ! congrats you have done a lisp

 

Thanks for your reply,but I do not know how to write lisp. can you help ?

Link to comment
Share on other sites

Ok

 

; box inside a circle by Alan H Aug 2016 using vl
(defun c:circbox ( / obj rad cen)
(setq obj (vlax-Ename->Vla-Object (car (entsel "pick circle"))))
(setq rad (vla-get-radius obj))
(setq cen (vlax-get obj 'center))
(setq pt2 (polar cen 0.0 rad))
(setq pt3 (polar pt2 (/ pi 2.0) rad))
(setq Pt4 (polar cen (/ pi 2.0) rad))
(command "pline" cen pt2 pt3 pt4 "C")
(command "rotate" "L" "" cen "drag")
)
(c:circbox) ; remove this later just for testing

 

; box inside a circle by Alan H Aug 2016 using assoc
(defun c:circbox ( / obj rad cen)
(setq obj (entget (car (entsel "pick circle"))))
(setq rad (cdr (assoc 40 obj)))
(setq cen (cdr (assoc 10 obj)))
(setq pt2 (polar cen 0.0 rad))
(setq pt3 (polar pt2 (/ pi 2.0) rad))
(setq Pt4 (polar cen (/ pi 2.0) rad))
(command "pline" cen pt2 pt3 pt4 "C")
(command "rotate" "L" "" cen "drag")
)
(c:circbox) ; remove this later just for testing

Link to comment
Share on other sites

  • 1 month later...

Do a bit of home work about using (setq ss (ssget '((0 . "Circle")))) then ssname, need to replace the entsel in code above with a repeat and loop through the selection set ss drawing the box around each circle.

 

This is a real common thing in lisp even just look at some of the posts in the LISP section.

 

If it gets to hard post again.

Link to comment
Share on other sites

Sorry!!I really do not know how to write lisp,but I will try to do.

Thank you very much

 

 

Do a bit of home work about using (setq ss (ssget '((0 . "Circle")))) then ssname, need to replace the entsel in code above with a repeat and loop through the selection set ss drawing the box around each circle.

 

This is a real common thing in lisp even just look at some of the posts in the LISP section.

 

If it gets to hard post again.

Link to comment
Share on other sites

Found a few minutes

 

; box inside a circle by Alan H Aug 2016 using vl
(defun AH:circbox (obj / rad cen pt2 pt3 pt4)
(setq rad (vla-get-radius obj))
(setq cen (vlax-get obj 'center))
(setq pt2 (polar cen 0.0 rad))
(setq pt3 (polar pt2 (/ pi 2.0) rad))
(setq Pt4 (polar cen (/ pi 2.0) rad))
(command "pline" cen pt2 pt3 pt4 "C")
(command "rotate" "L" "" cen (getpoint cen))
)
(defun c:circbox ( / x ss obj)
(setq oldsnap (getvar "osmode"))
(setvar "osmode" 0)
(setq ss (ssget '((0 . "Circle"))))
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(AH:circbox obj) 
) ; repeat
(setvar "osmode" oldsnap)
(princ)
) ; defun
(c:circbox)

Link to comment
Share on other sites

Thank you a lot!!!

I found this lisp before, too.

I would like to change angle for all I select, so...........

 

 

Found a few minutes

 

; box inside a circle by Alan H Aug 2016 using vl
(defun AH:circbox (obj / rad cen pt2 pt3 pt4)
(setq rad (vla-get-radius obj))
(setq cen (vlax-get obj 'center))
(setq pt2 (polar cen 0.0 rad))
(setq pt3 (polar pt2 (/ pi 2.0) rad))
(setq Pt4 (polar cen (/ pi 2.0) rad))
(command "pline" cen pt2 pt3 pt4 "C")
(command "rotate" "L" "" cen (getpoint cen))
)
(defun c:circbox ( / x ss obj)
(setq oldsnap (getvar "osmode"))
(setvar "osmode" 0)
(setq ss (ssget '((0 . "Circle"))))
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(AH:circbox obj) 
) ; repeat
(setvar "osmode" oldsnap)
(princ)
) ; defun
(c:circbox)

Link to comment
Share on other sites

Try this

 

;The dtr function converts degrees to radians
;The rtd function converts radians to degrees
(defun dtr (a)
(* pi (/ a 180.0))
)
;
(defun rtd (a)
(/ (* a 180.0) pi)
)
; box inside a circle by Alan H Aug 2016 using vl
(defun AH:circbox (obj / rad cen pt2 pt3 pt4)
(setq rad (vlax-get obj 'radius))
(setq cen (vlax-get obj 'center))
(setq pt2 (polar cen (+ ang 0.0) rad))
(setq pt3 (polar pt2 (+ ang (/ pi 2.0)) rad))
(setq Pt4 (polar cen (+ ang (/ pi 2.0)) rad))
(command "pline" cen pt2 pt3 pt4 "C")

)
(defun c:circbox ( / x ss obj ang)
(setq oldsnap (getvar "osmode"))
(setvar "osmode" 0)
(setq ang (dtr (getreal "\nEnter Angle")))
(setq ss (ssget '((0 . "Circle"))))
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(AH:circbox obj) 
) ; repeat
(setvar "osmode" oldsnap)
(princ)
) ; defun
(c:circbox)

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