伙计,希望这有帮助
如果需要,请告诉我,这里有一些注释
- (defun C:samp4 (/ hole)
- (vl-load-com)
- (setvar "cmdecho" 0)
- ;this creates the layer, Give it, name , colour , lintype. lineweight eg 030 and plot (t or nil)
- (defun MkLay (Nme Col lTyp lWgt Plt / lays lay) ;thank lee for this one
- (setq lays
- (vla-get-layers
- (vla-get-ActiveDocument
- (vlax-get-acad-object)
- )
- )
- lay
- (cond
- ((tblsearch "LAYER" Nme)
- (vla-item lays Nme)
- )
- (t (vla-add lays Nme))
- )
- )
- (and Col (vla-put-Color lay Col))
- (and lTyp (lTload lTyp) (vla-put-Linetype lay lTyp))
- (and lWgt (vla-put-LineWeight lay (eval (read (strcat "acLnWt" lWgt)))))
- (and (not Plt) (vla-put-Plottable lay :vlax-false))
- )
- ;this just searchs for line type, adds it if needed
- (defun lTload (lTyp)
- (or (tblsearch "LTYPE" lTyp)
- (vla-load
- (vla-get-Linetypes
- (vla-get-ActiveDocument
- (vlax-get-acad-object)
- )
- )
- lTyp "acad.lin"
- )
- )
- )
- ;this is your draw function
- ;because your codes where all the similar except layer & linetype
- (defun drawingstuff(a layername /)
- ;This searchs for layer
- (if (not(tblsearch "layer" layername))
- (MkLay layername 84 a 030 nil)
- )
- ;this changes the layer
- (setvar "clayer" layername)
- ;this sets up the width then exits it
- (command "pline" '(0 0 0) "width" "0.0" "0.0" //)
- ;returns cmdecho back, so it has promps for commands
- (setvar "cmdecho" 1)
- ;runs pline & lets user do what they want with it
- (command "pline")
- )
- ;loadinc dcl
- (setq dcl_id (load_dialog "samp3.dcl"))
- (if (not (new_dialog "samp3" dcl_id) )
- (progn
- (alert "Can not find you dcl file")
- (exit)
- )
- )
- ;will set the the flag to respected vale, and will set all the tiles to bank
- ;because there toggle boxes, they can be on all at once, so it stops it,
- ;it will the cheack if current tile is nil or not
- ;if it is set the flag nil
- (action_tile "T1" "(setq hole "TB1")(set_tile "T2" "0")(set_tile "T3" "0")(set_tile "T4" "0")(if (= (get_tile "T1") "0")(setq hole nil)))")
- (action_tile "T2" "(setq hole "TB2")(set_tile "T1" "0")(set_tile "T3" "0")(set_tile "T4" "0")(if (= (get_tile "T2") "0")(setq hole nil)))")
- (action_tile "T3" "(setq hole "TB3")(set_tile "T1" "0")(set_tile "T2" "0")(set_tile "T4" "0")(if (= (get_tile "T3") "0")(setq hole nil)))")
- (action_tile "T4" "(setq hole "TB4")(set_tile "T1" "0")(set_tile "T2" "0")(set_tile "T3" "0")(if (= (get_tile "T4") "0")(setq hole nil)))")
- (action_tile "cancel" "(done_dialog)(setq userclick nil)")
- (action_tile "accept" "(done_dialog)(setq userclick T))")
- (start_dialog)
- (unload_dialog dcl_id)
- ;if accepted
- ;search which flag is done, will the pass the line type value and layer name to the funtion
- (if userclick
- (cond
- ((= hole "TB1") (drawingstuff "CCC_DR_1500""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500"))
- ((= hole "TB2") (drawingstuff "CCC_DR_1350" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350"))
- ((= hole "TB3") (drawingstuff "CCC_DR_1200" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200"))
- ((= hole "TB4") (drawingstuff "CCC_DR_1050" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050"))
- (t (princ "\nNothing changed."))
- )
- )
- (princ)
- )
|