Jump to content

Help editing a LISP


JuniorNogueira

Recommended Posts

Hi all,

 

I would like some AutoLISP Expert to give me some advice and if possible help to edit the following LISP.

 

the first .LSP makes several rectangles to parti of 3 posts and works perfectly !!

 

until some adjustments that were made to get the second .LSP, the problem is precisely that.

 

this .LSP has several problems the first is that it loses the essence of the first, the rectangles made from it, depending on the

 

so that the points P1 P2 P3 are picked up, the rectangles are incorrectly made, also if the units of measure, are changed

 

the program has some bugs,

 

I also think the program is kinda heavy, it crashes every time we run the program.

 

if these problems were solved it would already be PERFECT.

 

but we will correct some more problems and if it were possible I would like to make some improvements.

 

I would like the rectangle of the "LAND" to be in the "CYAN" color and all others in the "RED" color.

 

2º the "CYAN" rectangle Stay on layer "01" and the "RED" rectangles stay on layer "02".

 

3 and the labels inside the rectangles ("00" "00 * blue color" "Construction" "Terrain") lay on layers 03 04 05 06 in the exact color of the label.

 

4th after all the rectangles I will explode and would like it to be in the layers mentioned above.

 

 

Thanks in advance for your help, and apologies for English, I live in Brazil and the translator does not translate correctly. :?

 

///////////////////////////// LISP 01 /////////////////////////////

 

 

(defun c:Subdivide ( / *error* vars vals p1 p2 p3 p4 ang n w)
(gc)
(vl-load-com)
(or *acad* (setq *acad* (vlax-get-acad-object)))
(or *doc* (setq *doc* (vla-get-ActiveDocument *acad*)))
(defun *error* (error)
(mapcar 'setvar vars vals)
(vla-endundomark *doc*)
(cond
((not error))
((wcmatch (strcase error) "*QUIT*,*CANCEL*"))
(1 (princ (strcat "\nERROR: " error)))
)
(princ)
)
(vla-endundomark *doc*)
(vla-startundomark *doc*)
(setq vars '("cmdecho" "osmode"))
(setq vals (mapcar 'getvar vars))
(mapcar 'setvar vars '(0 0))
(command "_.expert" (getvar "expert")) ;; dummy command
(and
(setq p1 (getpoint "\nP1 <Início da Edificação>: "))
(setq p2 (getpoint p1 "\nP2 <Comprimento da Edificação>: "))
(setq p3 (getpoint p2 "\nP3 <Comprimento da Quadra>: "))
(or
(not (equal (angle p1 p2)(angle p1 p3) 1e-4))
(alert "\nPoints are all in a straight line.")
)
(not (initget 7))
(setq n (getint "\nEnter quantity of parcels to create: "))
(setq ang (angle p2 p3))
(setq w (/ (distance p2 p3) n))
(repeat n
(setq p3 (polar p2 ang w)
p4 (polar p1 ang w)
)
(vl-cmdf "_.pline" p2 p3 p4 p1 "_C")
(setq p2 p3 p1 p4)
)
)
(*error* nil)
)
(defun c:SD ()(c:Subdivide))

 

///////////////////////////// LISP 02 /////////////////////////////

 

 

(defun c:Subdivide( / *error* bmakerec3vs vars vals ucsf p1 p2 p3 k n w h bnn )
 (gc)
 (vl-load-com)
 (or *acad* (setq *acad* (vlax-get-acad-object)))
 (or *doc* (setq *doc* (vla-get-ActiveDocument *acad*)))
 (defun *error* ( error )
   (mapcar 'setvar vars vals)
   (if ucsf
     (command-s "_.UCS" "_P")
   )
   (vla-endundomark *doc*)
   (cond
     ((not error))
     ((wcmatch (strcase error) "*QUIT*,*CANCEL*"))
     (1 (princ (strcat "\nERROR: " error)))
   )
   (princ)
 )

 (defun bmakerec3vs ( w h ts bn / p ss )
   (setq ss (ssadd))
   (vl-cmdf "_.RECTANGLE" '(0.0 0.0) (list w h))
   (ssadd (entlast) ss)
   (setq p (list (/ w 4.0) (/ h 2.0)))
   (vl-cmdf "_.TEXT" "_J" "_ML" p ts "" "00")
   (ssadd (entlast) ss)
   (vl-cmdf "_.BLOCK" bn '(0.0 0.0) ss)
   (while (< 0 (getvar 'cmdactive)) (vl-cmdf ""))
   (if (or (not (entlast)) (and (entlast) (not (ssmemb (entlast) ss))))
     (progn
       (vl-cmdf "_.INSERT" bn '(0.0 0.0))
       (while (< 0 (getvar 'cmdactive)) (vl-cmdf ""))
     )
   )
   
   (vl-cmdf "_.BEDIT" bn)
   (while (< 0 (getvar 'cmdactive)) (vl-cmdf ""))
   (vl-cmdf "_.CHANGE" "_ALL" "" "_P" "_C" "3")
   (while (< 0 (getvar 'cmdactive)) (vl-cmdf ""))
   (vl-cmdf "_.BPARAMETER" "_V" p)
   (while (< 0 (getvar 'cmdactive)) (vl-cmdf ""))
   (vl-cmdf "_.-BVSTATE" "_N" "Edificações" "_C")
   (vl-cmdf "_.-BVSTATE" "_D" "VisibilityState0")
   (vl-cmdf "_.-BVSTATE" "_N" "Construções" "_H")
   (setq ss (ssadd))
   (vl-cmdf "_.RECTANGLE" '(0.0 0.0) (list w h))
   (ssadd (entlast) ss)
   (vl-cmdf "_.TEXT" "_J" "_ML" p ts "" "Construção")
   (ssadd (entlast) ss)
   (vl-cmdf "_.CHANGE" ss "" "_P" "_C" "2")
   (while (< 0 (getvar 'cmdactive)) (vl-cmdf ""))
   (vl-cmdf "_.-BVSTATE" "_N" "Terrenos" "_H")
   (setq ss (ssadd))
   (vl-cmdf "_.RECTANGLE" '(0.0 0.0) (list w h))
   (ssadd (entlast) ss)
   (vl-cmdf "_.TEXT" "_J" "_ML" p ts "" "Terreno")
   (ssadd (entlast) ss)
   (vl-cmdf "_.CHANGE" ss "" "_P" "_C" "4")
   (while (< 0 (getvar 'cmdactive)) (vl-cmdf ""))
   (while (< 0 (getvar 'cmdactive)) (vl-cmdf ""))
   (vl-cmdf "_.-BVSTATE" "_N" "Comércios" "_H")
   (setq ss (ssadd))
   (vl-cmdf "_.RECTANGLE" '(0.0 0.0) (list w h))
   (ssadd (entlast) ss)
   (vl-cmdf "_.TEXT" "_J" "_ML" p ts "" "00")
   (ssadd (entlast) ss)
   (vl-cmdf "_.CHANGE" ss "" "_P" "_C" "5")
   (while (< 0 (getvar 'cmdactive)) (vl-cmdf ""))
   (vl-cmdf "_.BCLOSE")
   (while (< 0 (getvar 'cmdactive)) (vl-cmdf ""))
   (princ)
 )

 (or *k* (setq *k* 0))
 (vla-endundomark *doc*)
 (vla-startundomark *doc*)
 (if (= 0 (getvar 'worlducs))
   (progn
     (vl-cmdf "_.UCS" "_W")
     (setq ucsf t)
   )
 )
 (setq vars '("cmdecho" "osmode"))
 (setq vals (mapcar 'getvar vars))
 (mapcar 'setvar vars '(0 0))
 (if
   (and
     (setq p1 (getpoint "\nP1 <Início da Edificação>: "))
     (setq p2 (getpoint p1 "\nP2 <Comprimento da Edificação>: "))
     (setq p3 (getpoint p2 "\nP3 <Comprimento da Quadra>: "))
     (or
       (not (equal (angle p1 p2) (angle p1 p3) 1e-4))
       (alert "\nPoints are all in a straight line.")
     )
     (not (initget 7))
     (setq n (getint "\nQuantidade de Edificações ou Lotes: "))
     (setq h (/ (distance p2 p3) n))
     (setq w (distance p1 p2))
   )
   (progn
     (bmakerec3vs w h (/ h 4.0) (setq bnn (strcat "rec" (itoa (setq *k* (1+ *k*)))))) ;;;; Especifique diferentes textos em vez de (/ h 4.0) e seu nome exclusivo para bloco em vez de "rec" (você pode deixá-lo como novos nomes de blocos serão criados de acordo com o incremento da variável global * k *)
     (entdel (entlast))
     (vl-cmdf "_.UCS" "_3P" p2 p1)
     (while (< 0 (getvar 'cmdactive)) (vl-cmdf ""))
     (setq k -1)
     (repeat n
       (vl-cmdf "_.INSERT" bnn (list 0.0 (* h (setq k (1+ k)))))
       (while (< 0 (getvar 'cmdactive)) (vl-cmdf ""))
     )
     (vl-cmdf "_.UCS" "_P")
   )
 )
 (*error* nil)
)

(defun c:SD nil (c:Subdivide))

Subdivide.lsp

tmp.lsp

Edited by SLW210
Added Code Tags!
Link to comment
Share on other sites

Hi all,

 

I would like some AutoLISP Expert to give me some advice and if possible help to edit the following LISP.

 

the first .LSP makes several rectangles to parti of 3 posts and works perfectly !!

 

until some adjustments that were made to get the second .LSP, the problem is precisely that.

 

this .LSP has several problems the first is that it loses the essence of the first, the rectangles made from it, depending on the

 

so that the points P1 P2 P3 are picked up, the rectangles are incorrectly made, also if the units of measure, are changed

 

the program has some bugs,

 

I also think the program is kinda heavy, it crashes every time we run the program.

 

if these problems were solved it would already be PERFECT.

 

but we will correct some more problems and if it were possible I would like to make some improvements.

 

I would like the rectangle of the "LAND" to be in the "CYAN" color and all others in the "RED" color.

 

2º the "CYAN" rectangle Stay on layer "01" and the "RED" rectangles stay on layer "02".

 

3 and the labels inside the rectangles ("00" "00 * blue color" "Construction" "Terrain") lay on layers 03 04 05 06 in the exact color of the label.

 

4th after all the rectangles I will explode and would like it to be in the layers mentioned above.

 

 

Thanks in advance for your help, and apologies for English, I live in Brazil and the translator does not translate correctly.

Subdivide.lsp

tmp.lsp

Link to comment
Share on other sites

Oi @@ obrigado pela a ajuda, vou tentar me expressar melhor em portugues ou espanhou,

o que estou querendo é uma tarefa um pouco complicada no meu ponto de vista.

é assim tenho duas .lisp a primeira é a inicial, ela funciona perfeitamente, vou adicionar o video com o nome (video "primeira LSP" )

faz os retangulos sempre corretos como pode vê no video.

 

foram feitas algumas alterações e o resultado foi a segunda lisp, ela conta com alguns problemas, bugs entre outros, eu gostaria que a segunda mantesse o mesmo principio da primeira. se conseguir fazer isso, já estaria perfeito. (video "segunda LSP")

alem do fato de que se for alterada a unidade de medida ela apresenta um bug.

 

https://drive.google.com/file/d/1P2qgD-765O7z3dQtRXRtIHw-pvCT_DIP/view

 

https://drive.google.com/file/d/1Z914kQVntb1ZUoSUW-WlR9M0mw-cXp05/view

Link to comment
Share on other sites

Hola Junior , te olvidaste te SUBIR o enviarme por privado , el DWG, lamentamblemente y vaya a saber hasta cuando, creo que nunca , ACAD NO PUEDE EDITAR IMÁGENESS EN ACAD.

Luego es necesario que subas el DWG , no las imágenes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...