Insertar bloques dinámico con lisp
Publicado por Blanca (1 intervención) el 23/08/2023 12:37:06
Hola! Tengo este código que quiero utilizar para introducir un bloque dinámico de manera automática en sus coordenadas y algunas características, que ya están introducidas en el propio bloque.
Al meter la función IBD funciona, el nombre de apoyo lo pregunta, y el txt en el que introduzco los datos xy, longitud, distancias... tb lo pide. Llegado a ese punto me arroja error y no continua la rutina. Tengo la sospecha de que realmente no está cogiendo el bloque dinámico, peor no sé dónde está el fallo.
Muchas gracias por vuestra ayuda!
Al meter la función IBD funciona, el nombre de apoyo lo pregunta, y el txt en el que introduzco los datos xy, longitud, distancias... tb lo pide. Llegado a ese punto me arroja error y no continua la rutina. Tengo la sospecha de que realmente no está cogiendo el bloque dinámico, peor no sé dónde está el fallo.
Muchas gracias por vuestra ayuda!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
(defun c:IBD ()
(setq blkname (getstring "Ingrese el nombre del bloque dinámico: "))
(setq txtfile (getfiled "Selecciona el archivo de texto" "" "txt" 0))
(if txtfile
(progn
(setq file (open txtfile "r"))
(if file
(progn
(setq acad (vlax-get-acad-object))
(setq doc (vla-get-activedocument acad))
(while (setq line (read-line file))
(setq data (vl-string-split line " "))
(setq x (atof (nth 0 data)))
(setq y (atof (nth 1 data)))
(setq n-ap (nth 2 data))
(setq tipo-ap (if (< (length data) 4) "" (nth 3 data)))
(setq len1 (if (< (length data) 5) 0.0 (atof (nth 4 data))))
(setq len2 (if (< (length data) 6) 0.0 (atof (nth 5 data))))
(setq dist1 (if (< (length data) 7) 0.0 (atof (nth 6 data))))
(setq dist2 (if (< (length data) 8) 0.0 (atof (nth 7 data))))
(setq dist3 (if (< (length data) 9) 0.0 (atof (nth 8 data))))
(setq dist4 (if (< (length data) 10) 0.0 (atof (nth 9 data))))
(setq angle (if (< (length data) 11) 0.0 (atof (nth 10 data))))
(vla-startundomark doc)
(setq block (vla-insertblock doc
(vlax-3d-point (list x y 0))
blkname
1.0 1.0 1.0
angle))
(if (= (vla-get-hasattributes block) :vlax-true)
(progn
(vla-getattributes block)
(vla-getattributevalues block)
(foreach att (vla-get-attributes block)
(setq atttag (vla-get-tagstring att))
(setq attval (vla-get-textstring att))
(if (= atttag "TIPO-AP")
(vla-put-textstring att tipo-ap)
(if (= atttag "LONGITUD1")
(vla-put-textstring att (rtos len1))
(if (= atttag "LONGITUD2")
(vla-put-textstring att (rtos len2))
(if (= atttag "DISTANCIA1")
(vla-put-textstring att (rtos dist1))
(if (= atttag "DISTANCIA2")
(vla-put-textstring att (rtos dist2))
(if (= atttag "DISTANCIA3")
(vla-put-textstring att (rtos dist3))
(if (= atttag "DISTANCIA4")
(vla-put-textstring att (rtos dist4))
)
)
)
)
)
)
)
)
)
)
(vla-endundomark doc)
)
(close file)
(princ "\nBloques insertados desde el archivo.")
)
(princ "\nError al abrir el archivo.")
)
)
(princ "\nNo se seleccionó ningún archivo.")
)
(princ)
)
Valora esta pregunta


1