tomswons
-
Postów
2 -
Dołączył
-
Ostatnia wizyta
Odpowiedzi opublikowane przez tomswons
-
-
Cześć,
Próbuje opracować skrypt który:
1. Rozpoznaje zaznaczone napisy/bloki i wstawia potem przypisane do nich bloki w odpowiedniej kolejności.
-Jeśli blok/napis jest nie zdefiniowany w zestawieniu skryptu to prosi o podanie nazwy która sprawdzi z zestawieniem. Jesli jest poprawna to ją akceptuje jako rozpoznaną, jeśli nie jest prosi ponownie o wpisanie nazwy.
2. Bloki wstawiają się w wybranym punkcie, przy czym każdy kolejny zaznaczony obiekt jest odsunięty o pewną wartość od poprzedniego.
Stworzyłem kilka wersji i w każdej jest pewien problem 😕
1. Działa rozpoznawanie obiektów, ale pyta o nazwę nie znanego bloku dopiero gdy zakończę wybór zamiast odrazu gdy trafi się jakiś nie znany obiekt
(defun c:drawcircle() (setq selectionList (list)) (setq selection (entsel "Wybierz napis lub blok: ")) (while selection (setq selectionList (append selectionList (list (car selection)))) (setq selection (entsel "Wybierz kolejny napis lub blok lub zakończ wybór: ")) ) (if selectionList (progn (setq p1 (getpoint "Wybierz punkt wstawienia: ")) (setq offset 0) (foreach selection selectionList (setq entType (cdr (assoc 0 (entget selection)))) (setq entName (if (equal entType "TEXT") (cdr (assoc 1 (entget selection))) (cdr (assoc 2 (entget selection))))) (setq found nil) (foreach relation '(("bidet" . "svp_bidet") ("A$C70EE3DDA" . "svp_centrala")) (if (equal entName (car relation)) (progn (setq found t) (setvar "cmdecho" 0) (setvar "ATTDIA" 0) (setq insBlok (cdr relation)) (setq pt (polar p1 0 offset)) (command "_insert" insBlok pt "1" "1" "0") (setq offset (+ offset 2000)) (setvar "ATTDIA" 1) ) ) ) (if (not found) (while (not found) (setq insBlok (getstring "Podaj nazwę bloku dla napisu/bloku: ")) (foreach relation '(("bidet" . "svp_bidet") ("A$C70EE3DDA" . "svp_centrala")) (if (equal insBlok (car relation)) (progn (setq found t) (setvar "cmdecho" 0) (setvar "ATTDIA" 0) (setq insBlok (cdr relation)) (setq pt (polar p1 0 offset)) (command "_insert" insBlok pt "1" "1" "0") (setq offset (+ offset 2000)) (setvar "ATTDIA" 1) ) ) ) (if (not found) (alert "Nie ma takiego bloku w relacjach, spróbuj ponownie.")) ) ) ) ) (alert "Nie wybrano żadnego napisu lub bloku.") ) (princ) ) (princ "Polecenie DRAWCIRCLE wczytane.")
2. Nie rozpoznaje tekstu ani bloków zawsze pyta co to jest i wstawia je w odpowiedniej kolejności.(defun c:drawcircle() (setq selectionList (list)) (setq selection (entsel "Wybierz napis lub blok: ")) (while selection (setq entName (cdr (assoc 2 (entget (car selection))))) (setq found nil) (foreach relation '(("bidet" . "svp_bidet") ("centrala" . "svp_centrala")) (if (equal entName (car relation)) (setq found t) ) ) (if (not found) (while (not found) (setq entName (getstring "Podaj nazwę napisu/bloku: ")) (foreach relation '(("bidet" . "svp_bidet") ("centrala" . "svp_centrala")) (if (equal entName (car relation)) (setq found t) ) ) (if (not found) (alert "Nie ma takiego napisu/bloku w relacjach, spróbuj ponownie.")) ) ) (setq selectionList (append selectionList (list entName))) (setq selection (entsel "Wybierz kolejny napis lub blok lub zakończ wybór: ")) ) (if selectionList (progn (setq p1 (getpoint "Wybierz punkt wstawienia: ")) (setq offset 0) (foreach entName selectionList (foreach relation '(("bidet" . "svp_bidet") ("centrala" . "svp_centrala")) (if (equal entName (car relation)) (progn (setq insBlok (cdr relation)) (setq pt (polar p1 0 offset)) (command "_insert" insBlok pt "1" "1" "0") (setq offset (+ offset 1000)) ) ) ) ) ) (alert "Nie wybrano żadnego napisu lub bloku.") ) (princ) ) (princ "Polecenie DRAWCIRCLE wczytane.")
3. Rozpoznaje czy napis/blok jest zdefiniowany, prosi o podanie nazwy bloku jeśli nie jest. Niestety jednak niczego nie wstawia.
(defun c:drawcircle() (setq selectionList (list)) (setq selection (entsel "Wybierz napis lub blok: ")) (while selection (setq entType (cdr (assoc 0 (entget (car selection))))) (setq currEntName (if (equal entType "TEXT") (cdr (assoc 1 (entget (car selection)))) (cdr (assoc 2 (entget (car selection)))))) (setq found nil) (foreach relation '(("bidet" . "svp_bidet") ("A$C70EE3DDA" . "svp_centrala")) (if (equal currEntName (car relation)) (setq found t) ) ) (if (not found) (while (not found) (setq currEntName (getstring "Podaj nazwę napisu/bloku: ")) (foreach relation '(("bidet" . "svp_bidet") ("A$C70EE3DDA" . "svp_centrala")) (if (equal currEntName (car relation)) (setq found t) ) ) (if (not found) (alert "Nie ma takiego napisu/bloku w relacjach, spróbuj ponownie.")) ) ) (setq selectionList (append selectionList (list (car selection)))) (setq selection (entsel "Wybierz kolejny napis lub blok lub zakończ wybór: ")) ) (if selectionList (progn (setq p1 (getpoint "Wybierz punkt wstawienia: ")) (setq offset 0) (foreach selection selectionList (setq entType (cdr (assoc 0 (entget selection)))) (setq entName (if (equal entType "TEXT") (cdr (assoc 1 (entget selection))) (cdr (assoc 2 (entget selection))))) (foreach relation '(("bidet" . "svp_bidet") ("A$C70EE3DDA" . "svp_centrala")) (if (equal entName (car relation)) (progn (setvar "cmdecho" 0) (setvar "ATTDIA" 0) (setq insBlok (cdr relation)) (setq pt (polar p1 0 offset)) (command "_insert" insBlok pt "1" "1" "0") (setq offset (+ offset 1000)) (setvar "ATTDIA" 1) ) ) ) ) ) (alert "Nie wybrano żadnego napisu lub bloku.") ) (princ) ) (princ "Polecenie DRAWCIRCLE wczytane.")
4 Wstawia wielokrotnie tylko ostatnio wprowadzony obiekt, ale rozpoznaje tekst, bloki i pyta o nie znane elementy
(defun c:drawcircle() (setq selectionList (list)) (setq selection (entsel "Wybierz napis lub blok: ")) (while selection (setq entType (cdr (assoc 0 (entget (car selection))))) (setq entName (if (equal entType "TEXT") (cdr (assoc 1 (entget (car selection)))) (cdr (assoc 2 (entget (car selection)))))) (setq found nil) (foreach relation '(("bidet" . "svp_bidet") ("A$C70EE3DDA" . "svp_centrala")) (if (equal entName (car relation)) (setq found t) ) ) (if (not found) (while (not found) (setq entName (getstring "Podaj nazwę napisu/bloku: ")) (foreach relation '(("bidet" . "svp_bidet") ("A$C70EE3DDA" . "svp_centrala")) (if (equal entName (car relation)) (setq found t) ) ) (if (not found) (alert "Nie ma takiego napisu/bloku w relacjach, spróbuj ponownie.")) ) ) (setq selectionList (append selectionList (list (car selection)))) (setq selection (entsel "Wybierz kolejny napis lub blok lub zakończ wybór: ")) ) (if selectionList (progn (setq p1 (getpoint "Wybierz punkt wstawienia: ")) (setq offset 0) (foreach selection selectionList (foreach relation '(("bidet" . "svp_bidet") ("A$C70EE3DDA" . "svp_centrala")) (if (equal entName (car relation)) (progn (setvar "cmdecho" 0) (setvar "ATTDIA" 0) (setq insBlok (cdr relation)) (setq pt (polar p1 0 offset)) (command "_insert" insBlok pt "1" "1" "0") (setq offset (+ offset 1000)) (setvar "ATTDIA" 1) ) ) ) ) ) (alert "Nie wybrano żadnego napisu lub bloku.") ) (princ) ) (princ "Polecenie DRAWCIRCLE wczytane.")
5. Robi w sumie wszystko jak należy ale pozwala wybrać tylko 1 obiekt zamiast zapętlać funkcje wyboru.
(defun c:drawcircle() (setq selection (entsel "Wybierz napis lub blok: ")) (if selection (progn (setq entType (cdr (assoc 0 (entget (car selection))))) (setq entName (if (equal entType "TEXT") (cdr (assoc 1 (entget (car selection)))) (cdr (assoc 2 (entget (car selection)))))) (setq found nil) (foreach relation '(("bidet" . "svp_bidet") ("A$C70EE3DDA" . "svp_centrala")) (if (equal entName (car relation)) (progn (setq found t) (setvar "cmdecho" 0) (setvar "ATTDIA" 0) (setq insBlok (cdr relation)) (setq p1 (getpoint "Wybierz punkt wstawienia: ")) (command "_insert" insBlok p1 "1" "1" "0") (setvar "ATTDIA" 1) ) ) ) (if (not found) (while (not found) (setq insBlok (getstring "Podaj nazwę bloku dla napisu/bloku: ")) (foreach relation '(("bidet" . "svp_bidet") ("A$C70EE3DDA" . "svp_centrala")) (if (equal insBlok (car relation)) (progn (setq found t) (setvar "cmdecho" 0) (setvar "ATTDIA" 0) (setq insBlok (cdr relation)) (setq p1 (getpoint "Wybierz punkt wstawienia: ")) (command "_insert" insBlok p1 "1" "1" "0") (setvar "ATTDIA" 1) ) ) ) (if (not found) (alert "Nie ma takiego bloku w relacjach, spróbuj ponownie.")) ) ) ) (alert "Nie wybrano żadnego napisu lub bloku.") ) (princ) ) (princ "Polecenie DRAWCIRCLE wczytane.")
Skrypt AutocadLISP do rysowania rozwinięcia kanalizacji sanitarnej
w Wsparcie programistyczne LISP i VisualLISP
Opublikowano
Udało się A przynajmniej na razie nie znalazłem żadnego błędu
Gdyby ktoś miał jakieś sugestie to chętnie się zapoznam 😉