View Full Version : Ying and Yang
jlizard1
2006-07-20, 05:23 PM
Looking go a lisp program that will draw a Ying and Yang symbol inside a circle. Any help would be appreciated.
Tom Beauford
2006-07-20, 06:02 PM
That symbol is already in the wingdings font.
jlizard1
2006-07-20, 06:19 PM
Thanks Tom but I know it's in wingdings. I am actually looking for a lisp program that will draw it out. I use the symbol for the end of a water pipe. It's basically.. Draw a circle... draw a two point circle... pick top quadrant.. pick center.. draw two point circle.. pick bottom quadrant... pick center.. trim, select all three circles, pick opposite side of inside circles. That it. Now if I only knew how to write it in a lisp program.
CAB2k
2006-07-20, 06:29 PM
;; Draw a Ying Yang Symbol in a circle
;; CAB 07/20/2006
(defun c:yingyang (/ ent elst cen lay rad)
(and
(setq ent (car (entsel "\nSelect a circle.")))
(setq elst (entget ent))
(= "CIRCLE" (cdr (assoc 0 elst)))
(setq cen (cdr (assoc 10 elst))
lay (cdr (assoc 8 elst))
rad (/ (cdr (assoc 40 elst)) 2)
)
(entmake
(list (cons 0 "ARC")
(cons 8 lay)
(cons 10 (polar cen (/ pi 2) rad))
(cons 40 rad)
(cons 50 (/ pi 2))
(cons 51 (* pi 1.5))
)
)
(entmake
(list (cons 0 "ARC")
(cons 8 lay)
(cons 10 (polar cen (* pi 1.5) rad))
(cons 40 rad)
(cons 50 (* pi 1.5))
(cons 51 (/ pi 2))
)
)
)
(princ)
)
jlizard1
2006-07-20, 06:34 PM
It works!!! It works!!! Thanks CAB2k. I greatly appreciate it.
You Rock CAB2k!
I could have used this earlier today, great stuff.
Ted
Nothing against using LISP, but why not just use a block for this problem? :confused:
Nothing against using LISP, but why not just use a block for this problem? :confused:
Good question,
In my case I don't usually do allot of piping so i don't have a library of blocks like this, which I would have, if did piping.
So this works for me, I shortened the command to "yy", select the circle and it's done (real quick to get the job done).
I suppose a block created at "one unit" like this would be appropriate, if the pipe was three inches you would scale it upon insertion to "3" etc.
Ted
Good question,
In my case I don't usually do allot of piping so i don't have a library of blocks like this, which I would have, if did piping.
So this works for me, I shortened the command to "yy", select the circle and it's done (real quick to get the job done).
I suppose a block created at "one unit" like this would be appropriate, if the pipe was three inches you would scale it upon insertion to "3" etc.
Ted
That's what I was talking about. ;)
CAB2k
2006-07-21, 03:49 AM
Here is your block routine. :)
;;;=======================[ PipeEnd.lsp ]=======================
;;; Author: Copyright© 2006 Charles Alan Butler
;;; Version: 1.0 July 20, 2006
;;; Purpose: To insert a Pipe End Symbol.
;;; Requirements: User Pick pipe end (2 points)
;;;==============================================================
(defun c:pipeend (/)
;; ==================[ Functions ]======================
(defun make_pe_blk ()
(or
(progn
(entmake
(list '(0 . "BLOCK")
'(100 . "AcDbEntity")
'(100 . "AcDbBlockBegin")
(cons 2 "PipeEndBlk")
'(8 . "0")
'(70 . 0)
'(10 0.0 0.0 0.0)
)
)
(entmake '((0 . "ARC")
(8 . "0")
(10 0.25 0.1875 0.0)
(40 . 0.3125)
(100 . "AcDbArc")
(50 . 3.785093762383077)
(51 . 5.639684198386302)
)
)
(entmake '((0 . "ARC")
(8 . "0")
(10 0.75 -0.1875 0.0)
(40 . 0.3125)
(100 . "AcDbArc")
(50 . 0.643501108793284)
(51 . 2.498091544796511)
)
)
(entmake '((0 . "ARC")
(8 . "0")
(10 0.75 0.1875 0.0)
(40 . 0.3125)
(100 . "AcDbArc")
(50 . 3.785093762383076)
(51 . 5.639684198386302)
)
)
(entmake (list '(0 . "ENDBLK") ; required
'(100 . "AcDbBlockEnd") ; recommended
'(8 . "0") ; recommended
)
)
)
(prompt "\nERROR - Make block failed.")
)
)
(defun ins_pe_blk (pt sc ang)
(or
(progn
(entmake (list '(0 . "INSERT")
'(100 . "AcDbEntity")
'(8 . "0")
'(100 . "AcDbBlockReference")
'(66 . 1)
'(2 . "PipeEndBlk")
(cons 10 pt)
(cons 41 sc)
(cons 42 sc)
(cons 43 sc)
(cons 50 ang)
'(210 0.0 0.0 1.0)
)
)
(entmake (list '(0 . "SEQEND") '(100 . "AcDbEntity") '(8 . "0")))
)
(prompt "\nERROR - Insert block failed.")
)
)
;; o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
;; M A I N R O U T I N E
;; o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
(and
(setq p1 (getpoint "\nPick point 1."))
(setq p2 (getpoint "\nPick point 2."))
(setq scale (distance p1 p2))
(or (tblsearch "BLOCK" "MyBlock")
(make_pe_blk)
)
(ins_pe_blk p1 scale (angle p1 p2))
)
(princ)
)
(prompt "\n Pipe End creator loaded, Enter PipeEnd to run.")
(princ)
jlizard1
2006-07-21, 06:56 PM
Thanks again CAB2k!!! All the co-workers are thrilled. The block idea is ok but the first program works for the function we need. Hate to push it but is it possible to program in a hatch pattern of one side of the ying yang symbol. We use the hatch line pattern, angle 45°, 1.0 scale. Thanks again for your help.
boesiii
2006-07-21, 06:59 PM
Cab, what is the "(and" for?
CAB2k
2006-07-21, 07:13 PM
Cab, what is the "(and" for?
The AND will cause the lisp to quit if anything within the AND returns nil.
Like :
user failed to select an object
Object is not a CIRCLE
So the ENTMAKE will not be attempted if anything above it in the code failed.
You usually see it written like this:
<not tested>
(defun c:yingyang (/ ent elst cen lay rad)
(if (and (setq ent (car (entsel "\nSelect a circle.")))
(setq elst (entget ent))
)
(if (= "CIRCLE" (cdr (assoc 0 elst)))
(progn
(setq cen (cdr (assoc 10 elst))
lay (cdr (assoc 8 elst))
rad (/ (cdr (assoc 40 elst)) 2)
)
(entmake
(list (cons 0 "ARC")
(cons 8 lay)
(cons 10 (polar cen (/ pi 2) rad))
(cons 40 rad)
(cons 50 (/ pi 2))
(cons 51 (* pi 1.5))
)
)
(entmake
(list (cons 0 "ARC")
(cons 8 lay)
(cons 10 (polar cen (* pi 1.5) rad))
(cons 40 rad)
(cons 50 (* pi 1.5))
(cons 51 (/ pi 2))
)
)
)
)
)
)
(princ)
)
CAB2k
2006-07-21, 07:36 PM
Thanks again CAB2k!!! All the co-workers are thrilled. The block idea is ok but the first program works for the function we need. Hate to push it but is it possible to program in a hatch pattern of one side of the ying yang symbol. We use the hatch line pattern, angle 45°, 1.0 scale. Thanks again for your help.
You can play with this.
;; Draw a Ying Yang Symbol in a circle
;; CAB 07/21/2006
(defun c:yy (/ ent elst cen lay rad)
(and
(setq ent (car (entsel "\nSelect a circle.")))
(setq elst (entget ent))
(= "CIRCLE" (cdr (assoc 0 elst)))
(setq cen (cdr (assoc 10 elst))
lay (cdr (assoc 8 elst))
rad (/ (cdr (assoc 40 elst)) 2)
)
(entmake
(list (cons 0 "ARC")
(cons 8 lay)
(cons 10 (polar cen (/ pi 2) rad))
(cons 40 rad)
(cons 50 (/ pi 2))
(cons 51 (* pi 1.5))
)
)
(entmake
(list (cons 0 "ARC")
(cons 8 lay)
(cons 10 (polar cen (* pi 1.5) rad))
(cons 40 rad)
(cons 50 (* pi 1.5))
(cons 51 (/ pi 2))
)
)
(command "-BHATCH" "_P" "ANSI31" "1" "45" (polar cen 1.57 rad) "")
)
(princ)
)
jlizard1
2006-07-21, 08:39 PM
Thank you, thank you, CAB2k!! Tested it out and all I had to change is the "45" to "1" on the bhatch. Worked great. You are a hit with the co-workers. Thanks again for your time. I really appreciate it.
CAB2k
2006-07-21, 10:18 PM
Glad to have been of help. :)
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.