Đến nội dung


Hình ảnh
- - - - -

Nhờ các pro sửa lỗi Lisp giúp


  • Please log in to reply
21 replies to this topic

#21 phamthanhbinh

phamthanhbinh

    biết lệnh adcenter

  • Moderator
  • PipPipPipPipPipPipPip
  • 6009 Bài viết
Điểm đánh giá: 3113 (tuyệt vời)

Đã gửi 12 July 2014 - 01:14 AM

xin lỗi bác bình. cosd đậy a. trăm sự nhờ bác.

 

https://mail.google....=f_hxfy4of80

(Defun c:T6() (setvar "dimtxt" 2.5); cheu cao text
(setvar "dimdli" 2.8) ; k/c kich thuoc //
(setvar "dimasz" 1.2); do lon mui ten
(setvar "dimclre" 82) ; mau duong dong kich thuoc
(setvar "dimclrt" 82) ; mau text
(setvar "dimclrd" 82);  mau duong kich thuoc
(setvar "dimtad" 0)
(setvar "dimzin" 8)
(vl-load-com) 
(vl-cmdf "ucs" "W")
(vl-cmdf "LTSCALE" "3")
(vl-cmdf "undo" "be") 
(setq a (getpoint "\n xin chao! day la chuong trinh ve truc trong co khi. Duoc viet boi <<nguyenbd159@Gmail.com>>. hay nhap diem dau tien cua doan truc: "))
(setq b (getpoint a"\n VUI LONG NHAP CHIEU DAI DOAN TRUC : "))
(vl-cmdf ".line" a b "")
(if (= droffld nil) 
(setq droffld1 2.00) 
(setq droffld1 droffld) 
(setq 
droffld (GETREAL (strcat "\nVUI LONG NHAP DUONG KINH TRUC. SAU DO CHON DOAN THANG VUA VE TREN DESTOP : <" (rtos droffld1 2 2) ">")) 
(if (= droffld nil) 
(setq droffld droffld1) 
 
(if (= droffled nil) 
(setq droffled1 2.00) 
(setq droffled1 droffled) 
 
(if (= droffled nil) 
(setq droffled droffled1) 
 
 
(setq offlong (/ droffld 2))
(setq offle (+ offlong droffled))
 
(setq SS (ssget (list (cons 0 "arc,ellipse,lwpolyline,spline,line,circle")))) 
(setq i 0) 
(setq N (sslength ss)) 
(while (< i N) 
(setq TEXTENT (ssname SS i)) 
(setq luubatdiem (getvar "osmode")) 
(setvar "osmode" 0) 
 
(setq diemchuan (vlax-curve-getPointAtDist TEXTENT 0)) 
(setq diemdinhhuong (vlax-curve-getPointAtDist TEXTENT 0.01)) 
(setq goc (angle diemchuan diemdinhhuong)) 
(setq diembentrai (polar diemchuan (- goc (/ pi 2)) offle)) 
(setq diembenphai (polar diemchuan (+ goc (/ pi 2)) offle)) 
 
(vl-cmdf ".offset" offlong textent diembentrai "") 
(vl-cmdf ".offset" offlong textent diembenphai "") 
(vl-cmdf "CHANGE" "P" "" "Properties"  "Color"  "10" "" )
(vl-cmdf "CHANGE" "P" "" "Properties"  "lt"  "center" "" )
 
(setq i (1+ i)) 
(setvar "osmode" luubatdiem) 
 
(vl-cmdf "undo" "end")
(setvar "osmode" 15359)
(command "line" diembentrai diembenphai"")
(command "CIRCLE" "0,0" offlong "")
(command  "dimlinear" pause PAUSE "T" "%%C<>" pause "" "*Cancel*" " *Cancel*")
(vl-cmdf "ucs" "M"  PAUSE )
(vl-cmdf "qdim"  )
 
(Defun c:T6() (setvar "dimtxt" 2.5); cheu cao text
(setvar "dimdli" 2.8) ; k/c kich thuoc //
(setvar "dimasz" 1.2); do lon mui ten
(setvar "dimclre" 82) ; mau duong dong kich thuoc
(setvar "dimclrt" 82) ; mau text
(setvar "dimclrd" 82);  mau duong kich thuoc
(setvar "dimtad" 0)
(setvar "dimzin" 8)
(vl-load-com) 
(vl-cmdf "ucs" "W")
(vl-cmdf "LTSCALE" "3")
(vl-cmdf "undo" "be") 
(setq a (getpoint "\n xin chao! day la chuong trinh ve truc trong co khi. Duoc viet boi <<nguyenbd159@Gmail.com>>. hay nhap diem dau tien cua doan truc: "))
(setq b (getpoint a"\n VUI LONG NHAP CHIEU DAI DOAN TRUC : "))
(vl-cmdf ".line" a b "")
(if (= droffld nil) 
(setq droffld1 2.00) 
(setq droffld1 droffld) 
(setq 
droffld (GETREAL (strcat "\nVUI LONG NHAP DUONG KINH TRUC. SAU DO CHON DOAN THANG VUA VE TREN DESTOP : <" (rtos droffld1 2 2) ">")) 
(if (= droffld nil) 
(setq droffld droffld1) 
 
(if (= droffled nil) 
(setq droffled1 2.00) 
(setq droffled1 droffled) 
 
(if (= droffled nil) 
(setq droffled droffled1) 
 
 
(setq offlong (/ droffld 2))
(setq offle (+ offlong droffled))
 
(setq SS (ssget (list (cons 0 "arc,ellipse,lwpolyline,spline,line,circle")))) 
(setq i 0) 
(setq N (sslength ss)) 
(while (< i N) 
(setq TEXTENT (ssname SS i)) 
(setq luubatdiem (getvar "osmode")) 
(setvar "osmode" 0) 
 
(setq diemchuan (vlax-curve-getPointAtDist TEXTENT 0)) 
(setq diemdinhhuong (vlax-curve-getPointAtDist TEXTENT 0.01)) 
(setq goc (angle diemchuan diemdinhhuong)) 
(setq diembentrai (polar diemchuan (- goc (/ pi 2)) offle)) 
(setq diembenphai (polar diemchuan (+ goc (/ pi 2)) offle)) 
 
(vl-cmdf ".offset" offlong textent diembentrai "") 
(vl-cmdf ".offset" offlong textent diembenphai "") 
(vl-cmdf "CHANGE" "P" "" "Properties"  "Color"  "10" "" )
(vl-cmdf "CHANGE" "P" "" "Properties"  "lt"  "center" "" )
 
(setq i (1+ i)) 
(setvar "osmode" luubatdiem) 
 
(vl-cmdf "undo" "end")
(setvar "osmode" 15359)
(command "line" diembentrai diembenphai"")
(command "CIRCLE" "0,0" offlong "")
(command  "dimlinear" pause PAUSE "T" "%%C<>" pause "" "*Cancel*" " *Cancel*")
(vl-cmdf "ucs" "M"  PAUSE )
(vl-cmdf "qdim"  )
 
(Defun c:T6() (setvar "dimtxt" 2.5); cheu cao text
(setvar "dimdli" 2.8) ; k/c kich thuoc //
(setvar "dimasz" 1.2); do lon mui ten
(setvar "dimclre" 82) ; mau duong dong kich thuoc
(setvar "dimclrt" 82) ; mau text
(setvar "dimclrd" 82);  mau duong kich thuoc
(setvar "dimtad" 0)
(setvar "dimzin" 8)
(vl-load-com) 
(vl-cmdf "ucs" "W")
(vl-cmdf "LTSCALE" "3")
(vl-cmdf "undo" "be") 
(setq a (getpoint "\n xin chao! day la chuong trinh ve truc trong co khi. Duoc viet boi <<nguyenbd159@Gmail.com>>. hay nhap diem dau tien cua doan truc: "))
(setq b (getpoint a"\n VUI LONG NHAP CHIEU DAI DOAN TRUC : "))
(vl-cmdf ".line" a b "")
(if (= droffld nil) 
(setq droffld1 2.00) 
(setq droffld1 droffld) 
(setq 
droffld (GETREAL (strcat "\nVUI LONG NHAP DUONG KINH TRUC. SAU DO CHON DOAN THANG VUA VE TREN DESTOP : <" (rtos droffld1 2 2) ">")) 
(if (= droffld nil) 
(setq droffld droffld1) 
 
(if (= droffled nil) 
(setq droffled1 2.00) 
(setq droffled1 droffled) 
 
(if (= droffled nil) 
(setq droffled droffled1) 
 
 
(setq offlong (/ droffld 2))
(setq offle (+ offlong droffled))
 
(setq SS (ssget (list (cons 0 "arc,ellipse,lwpolyline,spline,line,circle")))) 
(setq i 0) 
(setq N (sslength ss)) 
(while (< i N) 
(setq TEXTENT (ssname SS i)) 
(setq luubatdiem (getvar "osmode")) 
(setvar "osmode" 0) 
 
(setq diemchuan (vlax-curve-getPointAtDist TEXTENT 0)) 
(setq diemdinhhuong (vlax-curve-getPointAtDist TEXTENT 0.01)) 
(setq goc (angle diemchuan diemdinhhuong)) 
(setq diembentrai (polar diemchuan (- goc (/ pi 2)) offle)) 
(setq diembenphai (polar diemchuan (+ goc (/ pi 2)) offle)) 
 
(vl-cmdf ".offset" offlong textent diembentrai "") 
(vl-cmdf ".offset" offlong textent diembenphai "") 
(vl-cmdf "CHANGE" "P" "" "Properties"  "Color"  "10" "" )
(vl-cmdf "CHANGE" "P" "" "Properties"  "lt"  "center" "" )
 
(setq i (1+ i)) 
(setvar "osmode" luubatdiem) 
 
(vl-cmdf "undo" "end")
(setvar "osmode" 15359)
(command "line" diembentrai diembenphai"")
(command "CIRCLE" "0,0" offlong "")
(command  "dimlinear" pause PAUSE "T" "%%C<>" pause "" "*Cancel*" " *Cancel*")
(vl-cmdf "ucs" "M"  PAUSE )
(vl-cmdf "qdim"  )
 
(Defun c:T6() (setvar "dimtxt" 2.5); cheu cao text
(setvar "dimdli" 2.8) ; k/c kich thuoc //
(setvar "dimasz" 1.2); do lon mui ten
(setvar "dimclre" 82) ; mau duong dong kich thuoc
(setvar "dimclrt" 82) ; mau text
(setvar "dimclrd" 82);  mau duong kich thuoc
(setvar "dimtad" 0)
(setvar "dimzin" 8)
(vl-load-com) 
(vl-cmdf "ucs" "W")
(vl-cmdf "LTSCALE" "3")
(vl-cmdf "undo" "be") 
(setq a (getpoint "\n xin chao! day la chuong trinh ve truc trong co khi. Duoc viet boi <<nguyenbd159@Gmail.com>>. hay nhap diem dau tien cua doan truc: "))
(setq b (getpoint a"\n VUI LONG NHAP CHIEU DAI DOAN TRUC : "))
(vl-cmdf ".line" a b "")
(if (= droffld nil) 
(setq droffld1 2.00) 
(setq droffld1 droffld) 
(setq 
droffld (GETREAL (strcat "\nVUI LONG NHAP DUONG KINH TRUC. SAU DO CHON DOAN THANG VUA VE TREN DESTOP : <" (rtos droffld1 2 2) ">")) 
(if (= droffld nil) 
(setq droffld droffld1) 
 
(if (= droffled nil) 
(setq droffled1 2.00) 
(setq droffled1 droffled) 
 
(if (= droffled nil) 
(setq droffled droffled1) 
 
 
(setq offlong (/ droffld 2))
(setq offle (+ offlong droffled))
 
(setq SS (ssget (list (cons 0 "arc,ellipse,lwpolyline,spline,line,circle")))) 
(setq i 0) 
(setq N (sslength ss)) 
(while (< i N) 
(setq TEXTENT (ssname SS i)) 
(setq luubatdiem (getvar "osmode")) 
(setvar "osmode" 0) 
 
(setq diemchuan (vlax-curve-getPointAtDist TEXTENT 0)) 
(setq diemdinhhuong (vlax-curve-getPointAtDist TEXTENT 0.01)) 
(setq goc (angle diemchuan diemdinhhuong)) 
(setq diembentrai (polar diemchuan (- goc (/ pi 2)) offle)) 
(setq diembenphai (polar diemchuan (+ goc (/ pi 2)) offle)) 
 
(vl-cmdf ".offset" offlong textent diembentrai "") 
(vl-cmdf ".offset" offlong textent diembenphai "") 
(vl-cmdf "CHANGE" "P" "" "Properties"  "Color"  "10" "" )
(vl-cmdf "CHANGE" "P" "" "Properties"  "lt"  "center" "" )
 
(setq i (1+ i)) 
(setvar "osmode" luubatdiem) 
 
(vl-cmdf "undo" "end")
(setvar "osmode" 15359)
(command "line" diembentrai diembenphai"")
(command "CIRCLE" "0,0" offlong "")
(command  "dimlinear" pause PAUSE "T" "%%C<>" pause "" "*Cancel*" " *Cancel*")
(vl-cmdf "ucs" "M"  PAUSE )
(vl-cmdf "qdim"  )
 
(Defun c:T6() (setvar "dimtxt" 2.5); cheu cao text
(setvar "dimdli" 2.8) ; k/c kich thuoc //
(setvar "dimasz" 1.2); do lon mui ten
(setvar "dimclre" 82) ; mau duong dong kich thuoc
(setvar "dimclrt" 82) ; mau text
(setvar "dimclrd" 82);  mau duong kich thuoc
(setvar "dimtad" 0)
(setvar "dimzin" 8)
(vl-load-com) 
(vl-cmdf "ucs" "W")
(vl-cmdf "LTSCALE" "3")
(vl-cmdf "undo" "be") 
(setq a (getpoint "\n xin chao! day la chuong trinh ve truc trong co khi. Duoc viet boi <<nguyenbd159@Gmail.com>>. hay nhap diem dau tien cua doan truc: "))
(setq b (getpoint a"\n VUI LONG NHAP CHIEU DAI DOAN TRUC : "))
(vl-cmdf ".line" a b "")
(if (= droffld nil) 
(setq droffld1 2.00) 
(setq droffld1 droffld) 
(setq 
droffld (GETREAL (strcat "\nVUI LONG NHAP DUONG KINH TRUC. SAU DO CHON DOAN THANG VUA VE TREN DESTOP : <" (rtos droffld1 2 2) ">")) 
(if (= droffld nil) 
(setq droffld droffld1) 
 
(if (= droffled nil) 
(setq droffled1 2.00) 
(setq droffled1 droffled) 
 
(if (= droffled nil) 
(setq droffled droffled1) 
 
 
(setq offlong (/ droffld 2))
(setq offle (+ offlong droffled))
 
(setq SS (ssget (list (cons 0 "arc,ellipse,lwpolyline,spline,line,circle")))) 
(setq i 0) 
(setq N (sslength ss)) 
(while (< i N) 
(setq TEXTENT (ssname SS i)) 
(setq luubatdiem (getvar "osmode")) 
(setvar "osmode" 0) 
 
(setq diemchuan (vlax-curve-getPointAtDist TEXTENT 0)) 
(setq diemdinhhuong (vlax-curve-getPointAtDist TEXTENT 0.01)) 
(setq goc (angle diemchuan diemdinhhuong)) 
(setq diembentrai (polar diemchuan (- goc (/ pi 2)) offle)) 
(setq diembenphai (polar diemchuan (+ goc (/ pi 2)) offle)) 
 
(vl-cmdf ".offset" offlong textent diembentrai "") 
(vl-cmdf ".offset" offlong textent diembenphai "") 
(vl-cmdf "CHANGE" "P" "" "Properties"  "Color"  "10" "" )
(vl-cmdf "CHANGE" "P" "" "Properties"  "lt"  "center" "" )
 
(setq i (1+ i)) 
(setvar "osmode" luubatdiem) 
 
(vl-cmdf "undo" "end")
(setvar "osmode" 15359)
(command "line" diembentrai diembenphai"")
(command "CIRCLE" "0,0" offlong "")
(command  "dimlinear" pause PAUSE "T" "%%C<>" pause "" "*Cancel*" " *Cancel*")
(vl-cmdf "ucs" "M"  PAUSE )
(vl-cmdf "qdim"  )

Hề hề hề,

Code của bạn vẽ thừa là do thằng offle đó. Bạn có thể thay thằng này trong hai dòng code :

 

(setq diembentrai (polar diemchuan (- goc (/ pi 2)) offle)) 

(setq diembenphai (polar diemchuan (+ goc (/ pi 2)) offle)) 

 

(setq diembentrai (polar diemchuan (- goc (/ pi 2)) offle)) 
(setq diembenphai (polar diemchuan (+ goc (/ pi 2)) offle)) 

bằng thằng oflong thì sẽ hết bị thừa.

Tuy nhiên code của bạn viết khá lủng củng và còn nhiều điều cần xem lại do cách nghĩ của bạn còn khá đơn giản.

Nếu bạn rảnh và có thời gian thì trao đổi qua yahoo mình sẽ nói rõ hơn.


  • 0
Chúc các quý Anh trên diễn đàn luôn khỏe, đẻ thêm được nhiều thứ để mót.

#22 nguyenbd1

nguyenbd1

    biết lệnh text

  • Members
  • PipPipPipPip
  • 276 Bài viết
Điểm đánh giá: 13 (tàm tạm)

Đã gửi 12 July 2014 - 06:11 PM

hay quá bác bình ơi. cảm ơn bác.. thật sự em còn gà con lắm bác à


  • 0