Author Topic: Help with a code  (Read 304 times)

0 Members and 1 Guest are viewing this topic.

PM

  • Newt
  • Posts: 188
Help with a code
« on: March 31, 2021, 01:54:32 AM »
Hi. I am trying to write a code for door frame. I want to trim the mangenta wall lines between the  two magenta vertical lines

Code - Auto/Visual Lisp: [Select]
  1.       (command "line" point1 point4 "")
  2.       (command "line" point2 point3 "")
  3.  

and i want to trim the windoor green (color 90) lines between the the  two green (color 90) vertical lines ,like the attach photo

Code - Auto/Visual Lisp: [Select]
  1.       (command "line" point5 point6 "")
  2.       (command "line" point7 point8 ""
  3.  

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ()
  2. (COMMAND "_layer" "_m" "WINDOOR" "_c" "90" "" "")
  3. (setvar "OSMODE" 41)
  4. (setq point1 (getpoint "\n1first insertion point:"))
  5. (if (/= point1 nil)
  6.   (setq point2 (getpoint "\n2second insertion point:"))
  7.   (if (/= point2 nil)
  8.    (progn  
  9.     (setq point3 (getpoint "\nopposite wall point:"))
  10.     (if (/= point3 nil)
  11.      (progn  
  12.       (setq x1 (car point1))
  13.       (setq y1 (cadr point1))
  14.       (setq h1 (caddr point1))
  15.       (setq x2 (car point2))
  16.       (setq y2 (cadr point2))
  17.       (setq h2 (caddr point2))
  18.       (setq x3 (car point3))
  19.       (setq y3 (cadr point3))
  20.       (setq h3 (caddr point3))
  21.       (setq gonia12 (+ (- (* 2 PI) (angle point1 point2)) (/ PI 2)))
  22.       (IF (> GONIA12 (* 2 PI)) (- GONIA12 (* 2 PI)))
  23.       (setq gonia21 (+ (- (* 2 PI) (angle point2 point1)) (/ PI 2)))
  24.       (IF (> GONIA21 (* 2 PI)) (- GONIA21 (* 2 PI)))
  25.       (setq gonia23 (+ (- (* 2 PI) (angle point2 point3)) (/ PI 2)))
  26.       (IF (> GONIA23 (* 2 PI)) (- GONIA23 (* 2 PI)))
  27.         (setq fld1 (rtos gonia12 3 4))
  28.         (setq fld2 (rtos gonia21 3 4))
  29.         (setq fld3 (rtos gonia23 3 4))
  30.         (prin1 (strcat "-->" fld1 fld2 fld3))
  31.       (setq anoigma (distance point1 point2))      
  32.       (setq paxos (distance point2 point3))
  33.       (setq x4 (+ x3 (* anoigma (sin gonia21))))      
  34.       (setq y4 (+ y3 (* anoigma (cos gonia21))))
  35.       (setq point4 (list x4 y4 0))    
  36.       (setq x5 (+ x1 (* 0.05 (sin gonia12))))      
  37.       (setq y5 (+ y1 (* 0.05 (cos gonia12))))
  38.       (setq point5 (list x5 y5 0))      
  39.       (setq x6 (+ x4 (* 0.05 (sin gonia12))))      
  40.       (setq y6 (+ y4 (* 0.05 (cos gonia12))))
  41.       (setq point6 (list x6 y6 0))      
  42.       (setq x7 (+ x2 (* 0.05 (sin gonia21))))      
  43.       (setq y7 (+ y2 (* 0.05 (cos gonia21))))
  44.       (setq point7 (list x7 y7 0))      
  45.       (setq x8 (+ x3 (* 0.05 (sin gonia21))))      
  46.       (setq y8 (+ y3 (* 0.05 (cos gonia21))))
  47.       (setq point8 (list x8 y8 0))
  48.      (command "OSNAP" "NONE" "")
  49.       (command "line" point1 point2 "")
  50.       (command "line" point3 point4 "")
  51.       (command "line" point5 point6 "")
  52.       (command "line" point7 point8 "")
  53.      (COMMAND "_layer" "_m" "WALLS" "_c" "6" "" "_lw" "0.5" "" "")
  54.       (command "line" point1 point4 "")
  55.       (command "line" point2 point3 "")
  56.       )
  57.      )
  58.     )
  59.    )
  60.   )
  61.  )
  62. )
  63.  


Thanks

PM

  • Newt
  • Posts: 188
Re: Help with a code
« Reply #1 on: March 31, 2021, 06:25:18 AM »
any ideas?

d2010

  • Newt
  • Posts: 154
Re: Help with a code
« Reply #2 on: March 31, 2021, 06:18:56 PM »
Code: [Select]
(Defun pp_mcptdoor( / $rr j_new point1 point2 point3 x1 y1 h1 x2 y2 h2 x3 y3 h3 gonia12 gonia21 gonia23)
/*c2s:
       j_new=list("WinDoor","Walls"),
       con_kpi();
       command("_layer","_m",cadr(j_new),"_c","6","","_lw","0.5","","");
       $rr=(car(dfn_layer_isexist(car(j_new)))<0)?dfn_layer_new(car(j_new),90,1,"");
       $rr=(cadr(dfn_layer_isexist(cadr(j_new)))<0)?dfn_layer_new(cadr(j_new),6,1,"");
       setvar("OSMODE",41);
       point1=getpoint("\n1.First insertion point:");
       point2=(point1 != nil)?getpoint(point1,"\n2.Second insertion point:"):nil;
       if (point2==nil) { alert(readme.txt);exit();};
       setvar("CLayer",car(j_new));
       point3=(point2 != nil)?getpoint(point2,"\n3.Opposite wall point:"):nil;
       point8=nil,
       gonia21=nil,
       gonia12=nil,
       gonia23=nil,
       x1=(point3)?car(point1):nil;
       if (x1) { y1=cadr(point1),h1=caddr(point1),
                 x2=car(point2),y2=cadr(point2), h2=caddr(point2),
                 x3=car(point3),y3=cadr(point3), h3=caddr(point3),
                 gonia12= ((kTwoPi)-angle(point1,point2))+ (kHalfPi),
                 gonia21= ((kTwoPi)-angle(point2,point1))+ (kHalfPi)),
                 gonia23= ((kTwoPi)-angle(point2,point3))+ (kHalfPi);
             };
      gonia12=(acand(gonia12,gonia12>kTwoPi))?(gonia12-kTwoPi):gonia12,
      gonia21=(acand(gonia21,gonia21>kTwoPi))?(gonia21-kTwoPi):gonia21,
      gonia23=(acand(gonia23,gonia23>kTwoPi))?(gonia23-kTwoPi):gonia23;
      fld1=(gonia12)?rtos(gonia12,3,4):nil,
      fld2=(gonia21)?rtos(gonia21,3,4):nil,
      fld3=(gonia23)?rtos(gonia23,3,4):nil;
      if (fld1&&fld2&&fld3)
            { prin1(strcat("-->",fld1,fld2,fld3));
              anoigma=distance(point1,point2);
              paxos=distance(point2,point3);
              x4= (x3+ (anoigma*sin(gonia21)));
              y4= (y3+ (anoigma*cos(gonia21)));
              point4=lISt(x4,y4,0);
              x5= (x1+ (0.05*sin(gonia12)));
              y5= (y1+ (0.05*cos(gonia12)));
             point5=lISt(x5,y5,0);
             x6= (x4+ (0.05*sin(gonia12)));
             y6= (y4+ (0.05*cos(gonia12)));
             point6=lISt(x6,y6,0);
             x7= (x2+ (0.05*sin(gonia21)));
             y7= (y2+ (0.05*cos(gonia21)));
             point7=lISt(x7,y7,0);
             x8= (x3+ (0.05*sin(gonia21)));
             y8= (y3+ (0.05*cos(gonia21)));
             point8=lISt(x8,y8,0);
       };
    if (point8!=nil)
           { j_nop=car(j_new);
             dfn_enamk_line(point1,point2,j_nop,12,"");
             dfn_enamk_line(point3,point4,j_nop,34,"");
             dfn_enamk_line(point5,point6,j_nop,56,"");
             dfn_enamk_line(point7,point8,j_nop,78,"");
             j_nop=cadr(j_new);
             dfn_enamk_line(point1,point4,j_nop,14,"");
             dfn_enamk_line(point2,point3,j_nop,23,"");
           };
*/
$rr)

Code - Auto/Visual Lisp: [Select]
  1. (Defun dfn_enamk_line(p1 p2 la color lt / $rr nfl)
  2.   (if (=  color nil) (setq;|a20225|;
  3.          color 256)) (setq;|a20253|;
  4.          la (if (>  la "") la (getvar "CLAYER"))
  5.          p1 (append (list 10) p1)
  6.          p2 (append (list 11) p2)
  7.          nfl (list (cons 0 "LINE") (cons 100 "AcDbEntity") (cons 8 la) (cons 100 "AcDbLine") p1 p2 (cons 62 color))) (if (>  lt "") (setq;|a20545|;
  8.          nfl (append nfl (list (cons 6 lt))))) (setq;|a20601|;
  9.          $rr (entmakex nfl)) (princ)
  10. $rr)
  11.  

any ideas?
You replace the (command "line" point1 point2) with (dfn_enamk_line...)
Code: [Select]
     (command "OSNAP" "NONE" "")
      (command "line" point1 point2 "")
      (command "line" point3 point4 "")
      (command "line" point5 point6 "")
      (command "line" point7 point8 "")
     (COMMAND "_layer" "_m" "WALLS" "_c" "6" "" "_lw" "0.5" "" "")
      (command "line" point1 point4 "")
      (command "line" point2 point3 "")
:thinking:

« Last Edit: April 01, 2021, 02:23:10 PM by d2010 »

BIGAL

  • Swamp Rat
  • Posts: 665
  • 30 + years of using Autocad
Re: Help with a code
« Reply #3 on: March 31, 2021, 07:44:33 PM »
If your interested this is very cheap, does windows and doors, roofs, elevations etc. Just PM me.



A man who never made a mistake never made anything

PM

  • Newt
  • Posts: 188
Re: Help with a code
« Reply #4 on: April 01, 2021, 11:49:35 AM »
Hi d2010 . Thanks for the reply, but i can not understand your code

what is
Code - Auto/Visual Lisp: [Select]
  1.  $rr=  
  2.  { j_nop=car(j_new);
  3.  

I never use them before. And i can not see anywere the command trim in your code. I want  to trim the lines between magenta and color 90 like the attach photo

d2010

  • Newt
  • Posts: 154
Re: Help with a code
« Reply #5 on: April 01, 2021, 02:06:17 PM »
Try this code.
You extract the command break
I do not push-here the mySource because I hope other user/s respond to you, other solution/s, more better, that I have my pocket.
« Last Edit: April 01, 2021, 02:25:45 PM by d2010 »

PM

  • Newt
  • Posts: 188
Re: Help with a code
« Reply #6 on: April 02, 2021, 04:52:21 AM »
TEE lisp is not doing what i am searching for.

Thanks

d2010

  • Newt
  • Posts: 154
Re: Help with a code
« Reply #7 on: April 02, 2021, 04:55:19 AM »
You,only,  extract the (command "break"..)  and you insert it into your-lisp.