Skip to content

Commit

Permalink
draw plan menu, map (wrapper for mapcar)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdsandifer committed Aug 3, 2016
1 parent 020418d commit b4f89f3
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 19 deletions.
89 changes: 76 additions & 13 deletions DRAW_PLAN.LSP
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
;; width, offsetting first point, and ;;
;; placing threaded terminal. ;;
;; ;;
;; 08/01/2016 ;;
;; - Added basic menu and dynamic function ;;
;; programming so "dp" always loads menu ;;
;; or runs the command if the menu has been ;;
;; already been seen. ;;
;; ;;
;; Todo: ;;
;; - Combine with PlanDrawGoal & Comm w/ ;;
;; appropriate options. ;;
Expand All @@ -74,12 +80,69 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(defun C:dp (/ *error* intPostBlock ctrLineLayer postLayer dimLayer dimOffset
snapMode infillStockLength postSpacing railWidth
isCableRailing isPicketRailing cableOffsetDistance
tagOffsetDistance tagLayer tagBlock cableLayer
placeDims placeEndPlates placePosts placeCenteLine
tagScale cableEndShortening placeRail)
;; Runs menu tool and then gets redefined to run the drawing command with
;; the newly selected options.

(defun C:dp ( / )
(eval (read "(c:dps)")))



;; Runs menu tool and then gets redefined to run the drawing command with
;; the newly selected options.

(defun C:dps ( / postSpacing railWidth)

(setq railWidth "3") ; default
(setq intPostBlock "BP")

; Run dialog box to get user input
; Warn if dialog fails and exit
; Define a function based on the input so settings are
; saved and can be easily repeated without choices needed each time

(setq setupDCLID (load_dialog "DrawPlanSetup.dcl"))

(if (not (new_dialog "DrawPlanSetup" setupDCLID))
(princ "\nDialog box not found in file!\n")
;(exit)
)


(action_tile "postSpacingBox"
"(setq postSpacing 48)")
(action_tile "woodButton"
"(setq railWidth \"2-11/16\")")


(action_tile "accept" "(done_dialog)(setq userChoice T)")
(action_tile "cancel" "(done_dialog)(setq userChoice nil)")

(start_dialog)
(unload_dialog setupDCLID)

(if (not userChoice)
(exit))


(setq functionDefinition (strcat
"(defun C:dp ( / )
(DrawPlan " (itoa postSpacing) " \"" railWidth "\" \"" intPostBlock "\")
(princ))"))
(eval (read functionDefinition))

(eval (read "(c:dp)"))
(princ))



;; Variable managenment function - run by dp

(defun DrawPlan ( postSpacing railWidth intPostBlock / *error* ctrLineLayer postLayer dimLayer dimOffset snapMode infillStockLength
isCableRailing isPicketRailing cableOffsetDistance
tagOffsetDistance tagLayer tagBlock cableLayer
placeDims placeEndPlates placePosts placeCenteLine
tagScale cableEndShortening placeRail)

; Sets the default error handler to a custom one, localization above
; causes it to be reset after this function finishes
Expand All @@ -96,13 +159,13 @@
(JD:SaveVar "clayer" 'systemVariables)

; Set block names
(setq intPostBlock "BP"
endPlateBlock "end_plate"
;(setq intPostBlock "BP"
(setq endPlateBlock "end_plate"
tagBlock "POST-DRILLED CALL-OUT")

; layer names
(setq ctrLineLayer "A-HRAL-CNTR"
postLayer "A-HRAL-BRKT"
(setq ctrLineLayer "Center"
postLayer "Detail"
dimLayer "Dims"
railLayer "1"
tagLayer "POST-TAG"
Expand All @@ -117,8 +180,8 @@
snapMode 64)

; rail options
(setq postSpacing 72)
(setq railWidth "2-11/16") ; String or integer works here
;(setq postSpacing 72)
;(setq railWidth "2-11/16") ; String or integer works here

; Set flags to control whether certain things are drawn
(setq isCableRailing T
Expand Down Expand Up @@ -195,7 +258,7 @@
(cond
(placeCenteLine
(setvar "clayer" ctrLineLayer)
(command "._pline" currentPt nextPt "")))
(command "._pline" currentPt "W" 0 0 nextPt "")))

(cond
(placeDims
Expand Down
40 changes: 40 additions & 0 deletions DrawPlanSetup.dcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
DrawPlanSetup : dialog { //dialog name
label = "Draw Plan Setup" ; //label (visible to user)

: row { //define row

: text {label = "Post Spacing";}

: edit_box {key = postSpacingBox; width = 4; value = "48";}

:boxed_radio_column { //define radio column
label = "Top Rail Type" ; //label

: radio_button { //define radion button
key = "s200Button" ; //name
label = "Series &200" ; //label
value = "1" ; //switch it on
} //end definition

: radio_button {
key = "s200xButton" ;
label = "Series 200&X" ;
}

: radio_button {
key = "woodButton" ;
label = "Wood Adapter" ;
}

: radio_button {
key = "s100Button" ;
label = "Series 100" ;
}
}


}

ok_cancel ; //predifined OK/Cancel

}
23 changes: 18 additions & 5 deletions FUNC_PROG.lsp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@


;|===={ Filter }============================|;
;| Applies a supplied comparison function |;
;| to a supplied list and returns a list |;
;| composed of values that returned true. |;
;| Returns a sublist of the supplied list |;
;| including only values that return true |;
;| when input to the supplied function. |;
;|------------------------------------------|;
;| Author: J.D. Sandifer Rev: 07/26/2016 |;
;|==========================================|;
Expand All @@ -36,15 +36,28 @@



;|===={ Map }===============================|;
;| Simple wrapper for the "mapcar" function |;
;| to allow it to be accessed by the more |;
;| common functional programming name. |;
;|------------------------------------------|;
;| Author: J.D. Sandifer Rev: 08/01/2016 |;
;|==========================================|;

(defun Map (theFunction theList / )
(mapcar theFunction theList))



;|===={ Reduce }============================|;
;| Applies a supplied function to the |;
;| first two values of the supplied list. |;
;| The result is then used as the first |;
;| value for the function and the next |;
;| value from the list is the second. This |;
;| continues until the list is *reduced* |;
;| to one value which is returned. |;
;| The given function must use two inputs. |;
;| to one value which is returned. The |;
;| given function must expect two inputs. |;
;|------------------------------------------|;
;| Author: J.D. Sandifer Rev: 07/26/2016 |;
;|==========================================|;
Expand Down
1 change: 0 additions & 1 deletion MACROS.lsp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@
(princ))")) ; End of defun string setq

;(princ functionToDefine)
(eval (read functionToDefine))

(eval (read "(c:pp)"))
Expand Down

0 comments on commit b4f89f3

Please sign in to comment.