Author Topic: Cant detect y coordinates  (Read 1267 times)

0 Members and 1 Guest are viewing this topic.

Adesu

  • Guest
Cant detect y coordinates
« on: August 08, 2007, 09:07:26 PM »
Hi Alls,
From yesterday I not yet got solution to find my problem....  :angel:, my code can not fill at coloumn second for Y coordinates.
look at below

Command: _text
Current text style:  "Standard"  Text height:  2.0000
Specify start point of text or [Justify/Style]:
Specify height <2.0000>: 2
Specify rotation angle of text <0>:
Enter text: ; error: bad argument type: numberp: nil

Enter text: *Cancel*

Code: [Select]
(defun c:test (/ om cntx dl el1 len p1 p10 p11 p12 p13 p14
p15 p16 p2 p3 p4 p5 p6 p7 p8 p9 x cx cxl cy
cyl len lst p1 p17 p18 p19 p20 p21 strx stry)
    (setq om (getvar "osmode"))
    (if
      (> om 0)
      (setvar "osmode" 0)
      ) ; if
    (create_table)
    (create_text)
    (setvar "osmode" om)
    )

  (defun create_table ()
    (setq len 10)
    (setq p1 '(0 0 0))        ;(getpoint "\nClick any location for table: "))
    (setq p2 (polar p1 0 5))
    (setq p3 (polar p2 0 20))
    (setq p4 (polar p3 0 20))
    (command "_line" p1 p4 "")
    (setq el1 (entlast))
    (command "_array" el1 "" "r" (+ len 1) "1" -5)
    (setq dl (* len 5))
    (setq p5 (polar p1 (* pi 1.5) dl))
    (command "_line" p1 p5 "")
    (setq p6 (polar p2 (* pi 1.5) dl))
    (command "_line" p2 p6 "")
    (setq p7 (polar p3 (* pi 1.5) dl))
    (command "_line" p3 p7 "")
    (setq p8 (polar p4 (* pi 1.5) dl))
    (command "_line" p4 p8 "")   
    (setq p9 (polar p1 (* pi 1.5) 4.5))
    (setq p10 (polar p9 0 1.5))
    (command "_text" p10 2 "" "No")
    (setq p11 (polar p10 0 5))
    (command "_text" p11 2 "" "X Coor")
    (setq p12 (polar p11 0 20))
    (command "_text" p12 2 "" "Y Coor")
    (setq p13 (polar p10 (* pi 1.5) 4.5))
    (setq p14 (polar p13 0 10))
    (command "_text" p14 2 "" "0.00")
    (setq p15 (polar p14 0 20))
    (command "_text" p15 2 "" "0.00")
    (setq cntx 0)
    (setq x 1)
    (repeat
      (- len 1)
      (setq p16 (list (car p13)(+ (cadr p13) cntx)(caddr p13)))
      (command "_text" p16 2 "" (itoa x) "")
      (setq cntx (+ -5 cntx))
      (setq x (1+ x))
      )
    (princ)
    )   ; defun

  (defun create_text ()
    (setq p1 '(0 0 0))
    (setq lst '((58.0 0.00)(-17.50 0.00)(8.75 15.16)(8.75 -15.16)
(58.0 0.00)(-17.50 0.00)(8.75 15.16)(8.75 -15.16)))
    (setq p17 (polar p1 (* pi 1.5) 14))
    (setq p18 (polar p17 0 10))
    (setq cx 0)
    (setq cxl 0)
    (setq len 10)
    (repeat
      (- len 1)
      (setq p19 (list (car p18)(+ (cadr p18) cx)(caddr p18)))
      (setq strx (car (nth cxl lst)))
      (command "_text" p19 2 "" (rtos strx 2 2))
      (setq cx (+ -5 cx))
      (setq cxl (1+ cxl))
      )
    (setq cy 0)
    (setq cyl 0)
    (repeat
      (- len 1)
      (setq p20 (polar p19 0 20))
      (setq p21 (list (car p20)(+ (cadr p20) cy)(caddr p20)))
      (setq stry (cadr (nth cyl lst)))
      (command "_text" p21 2 "" (rtos stry 2 2))
      (setq cy (+ -5 cy))
      (setq cyl (1+ cyl))     
      )  ; repeat
    (princ)
    )    ; defun 

highflyingbird

  • Bull Frog
  • Posts: 415
  • Later equals never.
Re: Cant detect y coordinates
« Reply #1 on: August 08, 2007, 10:16:58 PM »
 
Code: [Select]
(defun create_table ()
...
 (repeat (- len 1)
     (setq p16 (list (car p13) (+ (cadr p13) cntx) (caddr p13)))
     ;;(command "_text" p16 2 "" (itoa x) "")
     [color=red](command "_text" p16 2 "" (itoa x));-->1[/color]
     (setq cntx (+ -5 cntx))
     (setq x (1+ x))
  )
  (princ)
)

(defun create_text ()
  .....
  (repeat
    ;;(- len 1)
    [color=red](- len 2);-->2[/color]

     (setq p19 (list (car p18) (+ (cadr p18) cx) (caddr p18)))
     (setq strx (car (nth cxl lst)))
     (command "_text" p19 2 "" (rtos strx 2 2))
     (setq cx (+ -5 cx))
     (setq cxl (1+ cxl))
  )
  (setq cy 0)
  (setq cyl 0)
  (repeat
    ;;(- len 1)
    [color=red](- len 2);-->3[/color]
     ;;(setq p20 (polar p19 0 20));;
     [color=red](setq p20 (polar p18 0 20));-->4[/color]
     (setq p21 (list (car p20) (+ (cadr p20) cy) (caddr p20)))
     (setq stry (cadr (nth cyl lst)))
     (command "_text" p21 2 "" (rtos stry 2 2))
     (setq cy (+ -5 cy))
     (setq cyl (1+ cyl))
  ) ; repeat
  (princ)
)


« Last Edit: August 08, 2007, 10:18:41 PM by highflybird »
I am a bilingualist,Chinese and Chinglish.

Dream.Fei

  • Guest
Re: Cant detect y coordinates
« Reply #2 on: August 08, 2007, 10:23:16 PM »
how about this code?
Code: [Select]
(defun c:x1 (/ bak-p1      bak-p2 bak-p3      bak-p4 lst      n
     pt table-height table-p1    table-p2 table-p3    table-p4
     table-width-1      table-width-2      table-width-3      text-p1
     text-p2 text-p3     tmp-lst tmp-p1      tmp-p2 tmp-p3      tmp-p4
    )
  (setq lst '((58.0 0.00)
      (-17.50 0.00)
      (8.75 15.16)
      (8.75 -15.16)
      (58.0 0.00)
      (-17.50 0.00)
      (8.75 15.16)
      (8.75 -15.16)
     )
  )
  (setq table-height 5)
  (setq table-width-1 5)
  (setq table-width-2 20)
  (setq table-width-3 20)
  (setq pt '(0 0))
  (setq n 0)
  ;;BackUp
  (setq bak-p1 pt)
  (setq bak-p2 (polar bak-p1 0 table-width-1))
  (setq bak-p3 (polar bak-p2 0 table-width-2))
  (setq bak-p4 (polar bak-p3 0 table-width-3))
  ;;Main
  (repeat (length lst)
    (setq tmp-lst (nth n lst))
    ;; Great-table
    (setq table-p1 pt)
    (setq table-p2 (polar table-p1 0 table-width-1))
    (setq table-p3 (polar table-p2 0 table-width-2))
    (setq table-p4 (polar table-p3 0 table-width-3))
    (vl-cmdf "_.line" table-p1 table-p4 "")
    ;; Great-text
    (setq text-p1 (polar pt 0 (* table-width-1 0.3))
  text-p1 (polar text-p1 (* pi 1.5) (* table-height 0.5))
    )
    (setq text-p2 (polar text-p1 0 (* table-width-2 0.5)))
    (setq text-p3 (polar text-p2 0 table-width-3))
    (vl-cmdf "-text" "j" "ml" text-p1 2 "" (rtos n 2 0))
    (vl-cmdf "-text" "j" "ml" text-p2 2 "" (rtos (car tmp-lst) 2 2))
    (vl-cmdf "-text" "j" "ml" text-p3 2 "" (rtos (cadr tmp-lst) 2 2))

    (setq n (1+ n))
    (setq pt (polar pt (* pi 1.5) table-height))
  )
  (setq tmp-p1 pt)
  (setq tmp-p2 (polar tmp-p1 0 table-width-1))
  (setq tmp-p3 (polar tmp-p2 0 table-width-2))
  (setq tmp-p4 (polar tmp-p3 0 table-width-3))
  (vl-cmdf "line" bak-p1 tmp-p1 "")
  (vl-cmdf "line" bak-p2 tmp-p2 "")
  (vl-cmdf "line" bak-p3 tmp-p3 "")
  (vl-cmdf "line" bak-p4 tmp-p4 "")
  (vl-cmdf "line" tmp-p1 tmp-p4 "")
)
« Last Edit: August 09, 2007, 12:06:55 AM by Dream.Fei »

Adesu

  • Guest
Re: Cant detect y coordinates
« Reply #3 on: August 08, 2007, 10:23:35 PM »
Hi highflybird,
it's great, thanks you very much.


Adesu

  • Guest
Re: Cant detect y coordinates
« Reply #4 on: August 08, 2007, 10:25:43 PM »
Hi Dream.Fei ,
Nice too, thanks a lot.