平面図ツール

平面図ツール

[SD_2301] 通り芯、通り芯記号、寸法を作成

通り芯と通り芯記号と寸法を同時に作成するAutoLISPコマンドです。

A通り芯記号のタイプを選びます。
B通り芯の間隔は、数字をカンマで区切って入力します。繰り返しの場合は5000*3のように入力します。
C最初の通り芯にも記号を振るかどうかを選びます。
D寸法を付ける位置を選択します。

このような通り芯と寸法が同時に作成されます。

使用される寸法スタイルは現在の寸法スタイルが使用されます。
通り芯記号の大きさは縮尺(USERR1)によって決定されます。
なお、このコマンドで作成された各通り芯には、XDATAが埋め込まれ、展開図・断面図ツールで展開・断面を作成する時に、プログラムが通り芯番号を認識出来るようになっています。

(defun c:SD_2301 ( / PtL1A PtL1B PtLA PtL2B Off_X Off_Y m LastVal 
                    RegVal OffText NewOff ReptOff TLen TotalOffset 
                    x_Axis_option y_Axis_option txt_X txt_Y x_Dim_option y_Dim_option
                    TextXL TextYL LastObj ObjL GLayer GLayer1 GLayer2 GLayer3)

    (if (= SD:Lang "E")
        (princ "\n [SD_2301 ver.20211210] Griline, Grid Number, Dimensions")
        (princ "\n [SD_2301 ver.20211210] 通り芯・記号・寸法を作る")
    )
    (princ "\n **********************************")

    (load "SD_U")
    (setq *error* *myerror*)   
    (OpeningRoutine)
    
    (setq GLayer (Get_Layer "A11" T))
    (setq GLayer1 (Get_Layer "A12" T))
    (setq GLayer2 (Get_Layer "A61" T))
    (setq GLayer3 (Get_Layer "A03S" T))
    (setq LastObj (entlast))
    (show_SD_2301)
    (setq Off_X (TotalOffset_2301 txt_X))       ;TotalOffset
    (setq Off_Y (TotalOffset_2301 txt_Y))       ;TotalOffset
    (PointList_2301)    
    (Make_Grid_2301 PtL1A PtL1B GLayer nil)
    (Make_Grid_2301 PtL2A PtL2B GLayer T)
    (BubblePoint_2301)
    (PrepareTextL_2301)
    (setvar "OSMODE" 0)
    (setvar "CLAYER" GLayer2)
    (princ "\n x_Dim_option :  ")
    (princ x_Dim_option)
    (cond   ((= x_Dim_option "Top")
            (Make_Dims_2301 PtL1B 90.0)
            (Make_Guide_2301 PtL1B (* 0.5 pi))
            (Make_Guide_2301 (reverse PtL1B) (* 0.5 pi))
            (MakeBubble_2301 PtL1B_B (* 0.5 pi) TextXL)
            )
            ((= x_Dim_option "Bottom")
            (Make_Dims_2301 PtL1A -90.0)
            (Make_Guide_2301 PtL1A (* -0.5 pi))
            (Make_Guide_2301 (reverse PtL1A) (* -0.5 pi))
            (MakeBubble_2301 PtL1A_B (* -0.5 pi) TextXL)
            )
            (T
            (Make_Dims_2301 PtL1B 90.0)
            (Make_Dims_2301 PtL1A -90.0)
            (Make_Guide_2301 PtL1B (* 0.5 pi))
            (Make_Guide_2301 (reverse PtL1B) (* 0.5 pi))
            (Make_Guide_2301 PtL1A (* -0.5 pi))
            (Make_Guide_2301 (reverse PtL1A) (* -0.5 pi))
            (MakeBubble_2301 PtL1B_B (* 0.5 pi) TextXL)
            (MakeBubble_2301 PtL1A_B (* -0.5 pi) TextXL)
            )
    )
    (cond   ((= y_Dim_option "Left")
            (Make_Dims_2301 PtL2A 180.0)
            (Make_Guide_2301 PtL2A (* -1.0 pi))
            (Make_Guide_2301 (reverse PtL2A) (* -1.0 pi))
            (MakeBubble_2301 PtL2A_B (* -1.0 pi) TextYL)
            )
            ((= y_Dim_option "Right")
            (Make_Dims_2301 PtL2B 0.0)
            (Make_Guide_2301 PtL2B 0.0)
            (Make_Guide_2301 (reverse PtL2B) 0.0)
            (MakeBubble_2301 PtL2B_B 0.0 TextYL)
            )
            (T
            (Make_Dims_2301 PtL2A 180.0)
            (Make_Dims_2301 PtL2B 0.0)
            (Make_Guide_2301 PtL2A (* -1.0 pi))
            (Make_Guide_2301 (reverse PtL2A) (* -1.0 pi))
            (Make_Guide_2301 PtL2B 0.0)
            (Make_Guide_2301 (reverse PtL2B) 0.0)
            (MakeBubble_2301 PtL2A_B (* -1.0 pi) TextYL)
            (MakeBubble_2301 PtL2B_B 0.0 TextYL)
            )
    )
    (MakeBlock_2301)
    (write_Reg_SD_2301) 
    (ClosingRoutine)
    (setq *error* nil)
    (princ)
)
    

;*********MakeBlock_2301
(defun MakeBlock_2301()
    (if LastObj 
        (setq ObjL (list (setq ObjName(entnext LastObj))))
        (setq ObjL (list (setq ObjName(entnext))))
    )
    (while ObjName
        (if (setq ObjName (entnext ObjName))
            (setq ObjL (cons ObjName ObjL))
        )
    )
        
        
    (setq ObjL (reverse ObjL))
    (setvar "expert" 5)
    (setvar "OSMODE" 183)
    (command ".Block" "SDTemp" "0,0")
    (mapcar 'command ObjL)
    (command "")
    (command ".insert" "SDTemp" "S" 1.0 pause 0.0)
    (command "._explode" "L" )
    
)
;*********PrepareTextL
(defun PrepareTextL_2301()
    (cond   ((= x_Axis_option "opt_Txt_X")
                (setq m 1)
                (repeat (length PtL1A_B)
                    (setq TextXL (cons (strcat "X" (itoa m)) TextXL))
                    (setq m (1+ m))
                )
            )
            ((= x_Axis_option "opt_Num_X")
                (setq m 1)
                (repeat (length PtL1A_B)
                    (setq TextXL (cons (itoa m) TextXL))
                    (setq m (1+ m))
                )
            )
    )
    (setq TextXL (reverse TextXL))
    (cond   ((= y_Axis_option "opt_Txt_Y")
                (setq m 1)
                (repeat (length PtL2A_B)
                    (setq TextYL (cons (strcat "Y" (itoa m)) TextYL))
                    (setq m (1+ m))
                )
            )
            ((= y_Axis_option "F")
                (setq m 1)
                (repeat (length PtL2A_B)
                    (setq TextYL (cons (strcat (itoa m) "F") TextYL))
                    (setq m (1+ m))
                )
            )
            ((= y_Axis_option "FL")
                (setq m 1)
                (repeat (length PtL2A_B)
                    (setq TextYL (cons (strcat (itoa m) "FL") TextYL))
                    (setq m (1+ m))
                )
            )
            ((= y_Axis_option "opt_Num_Y")
                (setq m 65)
                (repeat (length PtL2A_B)
                    (setq TextYL (cons (chr m) TextYL))
                    (setq m (1+ m))
                )
            )
    )
    (setq TextYL (reverse TextYL))
)
;*********Text
(defun MakeText_2301(WordList  PointList )
    (mapcar '(lambda(x y)(SD:MakeText x y (* 3.0 (getvar "userr1")) 0.0 GLayer2))
            WordList PointList
    )
)
;*********BubblePoint
(defun BubblePoint_2301()
    (setq   PtL1A_B PtL1A
            PtL1B_B PtL1B
            PtL2A_B PtL2A
            PtL2B_B PtL2B
    )
    (if (= 1stX "0")(setq PtL1A_B (cdr PtL1A)))
    (if (= LastX "0")(setq PtL1A_B (reverse (cdr (reverse PtL1A_B)))))
    (if (= 1stX "0")(setq PtL1B_B (cdr PtL1B)))
    (if (= LastX "0")(setq PtL1B_B (reverse (cdr (reverse PtL1B_B)))))

    (if (= 1stY "0")(setq PtL2A_B (cdr PtL2A)))
    (if (= LastY "0")(setq PtL2A_B (reverse (cdr (reverse PtL2A_B)))))
    (if (= 1stY "0")(setq PtL2B_B (cdr PtL2B)))
    (if (= LastY "0")(setq PtL2B_B (reverse (cdr (reverse PtL2B_B)))))
    
)
;*********Make Bubble&Text
(defun MakeBubble_2301(PointList Ang4 WordList)
    (setq CenL (mapcar '(lambda(x)(polar x Ang4 (* (getvar "userr1") 32.0))) PointList))
    (mapcar '(lambda(x)(SD:MakeCircle x (* (getvar "userr1") 4.0) GLayer2)) CenL)
    (mapcar '(lambda(x y)(SD:MakeText x y (* 3.0 (getvar "userr1")) 0.0 GLayer2))
            WordList CenL
    )
)


;*********Draw Guide Line
(defun Make_Guide_2301 ( PointList Ang2)
    (SD:MakeLine 
        (setq p1 (car PointList))
        (polar  (car PointList) (setq Ang3 (+ pi (angle (car PointList)(car (reverse PointList)))))(* (getvar "userr1") 20.0)) 
        GLayer3
    )
    (repeat 3
        (SD:MakeLine 
            (setq p1 (polar p1 Ang2 (* (getvar "userr1") 7.0)))
            (polar  p1 Ang3 (* (getvar "userr1") 20.0)) 
            GLayer3
        )
    )
)
;*********Draw Dims
(defun Make_Dims_2301(PointList Ang1)
    (mapcar '(lambda (x y)
	(if (< (atoi (getvar "acadver")) 20)
        		(command "dimrotated" (- Ang1 90.0) x y (polar (car PointList) (* pi (/ Ang1 180.0)) (*  (getvar "userr1") 14.0)))
		(command-s "dimrotated" (- Ang1 90.0) x y (polar (car PointList) (* pi (/ Ang1 180.0)) (*  (getvar "userr1") 14.0)))))
        PointList (cdr PointList)
    )
    (command "dimrotated" 
        (- Ang1 90.0) (car PointList) (car(reverse PointList))(polar (car PointList) (* pi (/ Ang1 180.0)) (*  (getvar "userr1") 21.0))
    )
)

;*********Point List
(defun PointList_2301()
    ;X
    (setq PtL1A (list (list  0 (* -40.0 (getvar "userr1")))))
    (setq    m 0
            LastVal 0.0
    )
    (repeat (length (nth 0 Off_X))
        (setq PtL1A (cons (list (setq LastVal (+ LastVal (nth m (nth 0 Off_X))))(* -40.0 (getvar "userr1"))) PtL1A))
        (setq m (1+ m))
    )
    
    (setq PtL1A (reverse PtL1A))
    (setq theY (+ (nth 2 Off_Y)(* 40.0 (getvar "userr1"))))
    (setq PtL1B (mapcar '(lambda(x)(list (car x) theY)) PtL1A))
    ;Y
    (setq PtL2A (list (list  (* -40.0 (getvar "userr1")) 0)))
    (setq    m 0
            LastVal 0.0
    )
    (repeat (length (nth 0 Off_Y))
        (setq PtL2A (cons (list (* -40.0 (getvar "userr1")) (setq LastVal (+ LastVal (nth m (nth 0 Off_Y))))) PtL2A))
        (setq m (1+ m))
    )
    (setq PtL2A (reverse PtL2A))
    (setq theX (+ (nth 2 Off_X)(* 40.0 (getvar "userr1"))))
    (setq PtL2B (mapcar '(lambda(x)(list theX (cadr x) )) PtL2A))
    
)
;*********Draw Grids
(defun Make_Grid_2301( PointListA PointListB theLayer flag / namlst m)
    (setq namlst (mapcar '(lambda(x y)(SD:MakeLine x y theLayer)) PointListA PointListB))
    (if flag
        (progn
            (if (= 1stY "0")(command "chprop" (car namlst) "" "la" GLayer1 ""))
            (if (= LastY "0")(command "chprop" (last namlst) "" "la" GLayer1 ""))
        )
        (progn
            (if (= 1stX "0")(command "chprop" (car namlst) "" "la" GLayer1 ""))
            (if (= LastX "0")(command "chprop" (last namlst) "" "la" GLayer1 ""))
        )
    )
	(if (null (tblsearch "APPID" "Grid"))(regapp "Grid"))
	(if flag (setq str1 "Y")(setq str1 "X"))
	(setq m 0)
	;(princ "\nnamlst: ")(princ namlst)
	(mapcar '(lambda (x)(entmod (append (entget x)(list (list -3 (list "Grid" (cons 1000 (strcat str1 (itoa (setq m (1+ m))))))))))) namlst)
)
;*********
(defun TotalOffset_2301( OffText / NewOff RegVal)
    (setq RegVal "")
    (setq OffText (SD4958 OffText))
    (setq OffText (y_str_separate "," OffText))
    (foreach item OffText
        (if (vl-string-position (ascii "*") item)
            (progn
                (setq ReptOff (y_str_separate "*" Item))
                (repeat (atoi (cadr ReptOff))
                    (setq NewOff (cons (distof (car ReptOff)2) NewOff))
                )
                (setq RegVal (strcat RegVal "," item))
            )
            (progn
                (setq NewOff (cons (if (distof item 2) (distof item 2) 0.0) NewOff))
                (if (distof item 2)(setq RegVal (strcat RegVal "," item)))
            )
        )
    )
    (setq NewOff (reverse NewOff))
    (setq RegVal (vl-string-left-trim "," RegVal))
    (setq TLen 0.0)
    (foreach Item NewOff
        (setq TLen (+ TLen item ))
    )
    (setq TotalOffset (list NewOff RegVal TLen))
    TotalOffset
)

;;;;*********;Save Registry
(defun write_Reg_SD_2301 ()
  (vl-registry-write Path_2301 "x_Axis_option" x_Axis_option)
  (vl-registry-write Path_2301 "txt_X" (nth 1 Off_X))
  (vl-registry-write Path_2301 "x_Dim_option" x_Dim_option)
  (vl-registry-write Path_2301 "y_Axis_option" y_Axis_option)
  (vl-registry-write Path_2301 "txt_Y" (nth 1 Off_Y))
  (vl-registry-write Path_2301 "y_Dim_option" y_Dim_option)
  (vl-registry-write Path_2301 "1stX" 1stX)
  (vl-registry-write Path_2301 "LastX" LastX)
  (vl-registry-write Path_2301 "1stY" 1stY)
  (vl-registry-write Path_2301 "LastY" LastY)
)

;;;;*****************;Read Registry
(defun read_Reg_SD_2301 ()
  (setq Path_2301
         "HKEY_CURRENT_USER\\Software\\SpeedDraft\\SD_2301")
  (if (vl-registry-read Path_2301 "x_Axis_option")
    (setq x_Axis_option (vl-registry-read Path_2301 "x_Axis_option"))
    (setq x_Axis_option "opt_Txt_X")
  )
  (if (vl-registry-read Path_2301 "txt_X")
    (setq txt_X (vl-registry-read Path_2301 "txt_X"))
    (setq txt_X "400,6300,5500*3,400")
  )

  (if (vl-registry-read Path_2301 "x_Dim_option")
    (setq x_Dim_option (vl-registry-read Path_2301 "x_Dim_option"))
    (setq x_Dim_option "Top")
  )

  (if (vl-registry-read Path_2301 "y_Axis_option")
    (setq y_Axis_option (vl-registry-read Path_2301 "y_Axis_option"))
    (setq y_Axis_option "opt_Txt_Y")
  )

  (if (vl-registry-read Path_2301 "txt_Y")
    (setq txt_Y (vl-registry-read Path_2301 "txt_Y"))
    (setq txt_Y "300,5000*4,500")
  )

  (if (vl-registry-read Path_2301 "y_Dim_option")
    (setq y_Dim_option (vl-registry-read Path_2301 "y_Dim_option"))
    (setq y_Dim_option "Left")
  )
  
  (if (vl-registry-read Path_2301 "1stX")
    (setq 1stX (vl-registry-read Path_2301 "1stX"))
    (setq 1stX "0")
  )
  (if (vl-registry-read Path_2301 "LastX")
    (setq LastX (vl-registry-read Path_2301 "LastX"))
    (setq LastX "")
  )
  (if (vl-registry-read Path_2301 "1stY")
    (setq 1stY (vl-registry-read Path_2301 "1stY"))
    (setq 1stY "0")
  )
  (if (vl-registry-read Path_2301 "LastY")
    (setq LastY (vl-registry-read Path_2301 "LastY"))
    (setq LastY "0")
  )
)

 ;*******;Show Dialogue
(defun show_SD_2301 ()
    (setq dcl_id (load_dialog "SD_2301.dcl"))
    (if (= SD:Lang "E")
        (new_dialog "SD_2301" dcl_id)
        (new_dialog "SD_2301_J" dcl_id)
    )

    (read_Reg_SD_2301)

    (set_tile "x_Axis_option" x_Axis_option)
    (set_tile "y_Axis_option" y_Axis_option)
    (set_tile "txt_X" txt_X)
    (set_tile "txt_Y" txt_Y)
    (set_tile x_Dim_option "1")
    (set_tile y_Dim_option "1")
    (set_tile "1stX" 1stX)
    (set_tile "LastX" LastX)
    (set_tile "1stY" 1stY)
    (set_tile "LastY" LastY)    

    (action_tile "accept" "(get_data_2301)(done_dialog 1)")
    (action_tile "cancel" "(done_dialog 0)")
    (setq Act (start_dialog))
    (unload_dialog dcl_id)
    (if (= Act 0)(exit))
)
 ;*****************
(defun get_data_2301 ()
  (setq x_Axis_option (get_tile "x_Axis_option")
        y_Axis_option (get_tile "y_Axis_option")
        txt_X         (get_tile "txt_X")
        txt_Y         (get_tile "txt_Y")
        x_Dim_option  (get_tile "x_Dim_option")
        y_Dim_option  (get_tile "y_Dim_option")
        1stX        (get_tile  "1stX")
        LastX       (get_tile  "LastX")
        1stY        (get_tile  "1stY")
        LastY       (get_tile  "LastY")     
  )
)
(princ )
SD_2301:dialog{initial_focus="txt_X";label = "Create Plan Gridlines";
  :column{
     :row{
           :column{label = "X- Axis";
              :spacer {}
              width = 40;
              : radio_row {label = "Mark";alignment = centered ;fixed_width = true;width = 38; key = "x_Axis_option";
              : radio_button {label = "X"; key = "opt_Txt_X";} 
              : radio_button { label = "1"; key = "opt_Num_X";}
              }
              :spacer {}
              :column{label = "Offset Values";fixed_width = true;width = 38;alignment = centered ;: text { value = "e.g.400,6300,5500*3,400";}
              :edit_box{allow_accept=true;key="txt_X";allow_accept=true;edit_width=34;fixed_width=true;}
              :toggle{key="1stX";label="Add Bubble on 1st Gridline";}
              :toggle{key="LastX";label="Add Bubble on Last Gridline";}
              :spacer {}
              }
              :spacer {}
              : radio_row {key = "x_Dim_option";label = "Location of Dimension";fixed_width = true;width = 38;alignment = centered ;
              : radio_button {label = "Top"; key = "Top";} 
              : radio_button { label = "Bottom"; key = "Bottom";}
              : radio_button { label = "Both"; key = "X_Both";}
              }
              :spacer {}
           }
        :spacer {}
              :column{
              label = "Y- Axis";
              :spacer {}
              width = 40;
              : radio_row {key = "y_Axis_option";label = "Mark";alignment = centered ;fixed_width = true;width = 38;
              : radio_button {label = "Y"; key = "opt_Txt_Y";} 
              : radio_button { label = "A"; key = "opt_Num_Y";}
              }
              :spacer {}
              :column{label = "Offset Values";fixed_width = true;width = 38;alignment = centered ;
              : text { value = "e.g.300,5000*4,500";}
              :edit_box{key="txt_Y";allow_accept=true;edit_width=34;fixed_width=true;}
              :toggle{key="1stY";label="Add Bubble on 1st Gridline";}
              :toggle{key="LastY";label="Add Bubble on Last Gridline";}
              :spacer {}
              }
              :spacer {}
              : radio_row {label = "Location of Dimension";fixed_width = true;width = 38;alignment = centered ; key = "y_Dim_option";
              : radio_button {label = "Left"; key = "Left";} 
              : radio_button { label = "Right"; key = "Right";}
              : radio_button { label = "Both"; key = "Y_Both";}
              }
              :spacer {}
              }
        }
      ok_cancel;
  }
}


SD_2301_J:dialog{initial_focus="txt_X";label = "通り芯作成";
  :column{
     :row{
           :column{label = "X- Axis";
              :spacer {}
              width = 40;
              : radio_row {label = "通り芯記号";alignment = centered ;fixed_width = true;width = 38; key = "x_Axis_option";
              : radio_button {label = "X"; key = "opt_Txt_X";} 
              : radio_button { label = "1"; key = "opt_Num_X";}
              }
              :spacer {}
              :column{label = "通り芯間隔";fixed_width = true;width = 38;alignment = centered ;
              : text { value = "例:400,6300,5500*3,400";}
              :edit_box{allow_accept=true;key="txt_X";allow_accept=true;edit_width=34;fixed_width=true;}
              :toggle{key="1stX";label="最初の通り芯にも記号を付ける";}
              :toggle{key="LastX";label="最後の通り芯にも記号を付ける";}
              :spacer {}
              }
              :spacer {}
              : radio_row {key = "x_Dim_option";label = "寸法をつける位置";fixed_width = true;width = 38;alignment = centered ;
              : radio_button {label = "上"; key = "Top";} 
              : radio_button { label = "下"; key = "Bottom";}
              : radio_button { label = "両方"; key = "X_Both";}
              }
              :spacer {}
           }
        :spacer {}
              :column{
              label = "Y- Axis";
              :spacer {}
              width = 40;
              : radio_row {key = "y_Axis_option";label = "符号";alignment = centered ;fixed_width = true;width = 38;
              : radio_button {label = "Y"; key = "opt_Txt_Y";} 
              : radio_button { label = "A"; key = "opt_Num_Y";}
              }
              :spacer {}
              :column{label = "通り芯間隔";fixed_width = true;width = 38;alignment = centered ;
              : text { value = "例:300,5000*4,500";}
              :edit_box{key="txt_Y";allow_accept=true;edit_width=34;fixed_width=true;}
              :toggle{key="1stY";label="最初の通り芯にも記号を付ける";}
              :toggle{key="LastY";label="最後の通り芯にも記号を付ける";}
              :spacer {}
              }
              :spacer {}
              : radio_row {label = "寸法をつける位置";fixed_width = true;width = 38;alignment = centered ; key = "y_Dim_option";
              : radio_button {label = "左"; key = "Left";} 
              : radio_button { label = "右"; key = "Right";}
              : radio_button { label = "両方"; key = "Y_Both";}
              }
              :spacer {}
              }
        }
      ok_cancel;
  }
}

コメント

この記事へのコメントはありません。

アップロードファイルの最大サイズ: 5 MB。 画像 をアップロードできます。 ここにファイルをドロップ

TOP