仍在学习,但现在试图做一个“L”形。
感谢每一位帮助我最后一次尝试**** Hidden Message ***** 嗨,这是一个简单的例子。不确定这是否是你所追求的 -
; Sample chart:
;
; pt_legYaxis
; || ipt_legYaxis
; ||
; ||
; || ipt
; ||___________ ipt_legXaxis
; pt |________________ pt_legXaxis
;
;
(defun C:BAA ( / pt LG1 LG2 THK1 pt_legYaxis pt_legXaxis ipt_legYaxis ipt_legXaxis ipt ) ; always localise your variables
(if
(and ; code block that collects all the user's inputs
(setq pt (getpoint "Choose a starting point"))
(setq LG1 (getreal "How long is the 1st leg?"))
(setq LG2 (getreal "How long is the 2nd leg?"))
(setq THK1 (getreal "How thick is the member?"))
); and
(progn ; code block that processes the inputs
(setq pt_legYaxis (mapcar '+ pt (list 0.0 LG1 0.0))) ; calculate the vertical leg by adding 'LG1' distance to 'pt's Y coordinate
(setq pt_legXaxis (mapcar '+ pt (list LG2 0.0 0.0))) ; calculate the horizontal leg by adding 'LG2' distance to 'pt's X coordinate
(setq ipt_legYaxis (mapcar '+ pt_legYaxis (list THK1 0.0 0.0))) ; calculate the inner top vertex by adding 'THK1' distance on 'ipt_legYaxis' s X coordinate
(setq ipt_legXaxis (mapcar '+ pt_legXaxis (list 0.0 THK1 0.0))) ; calculate the inner bottom vertex by adding 'THK1' distance on 'ipt_legXaxis' s Y coordinate
(setq ipt (mapcar '+ pt (list THK1 THK1 0.0))) ; calculate the inner intersection by adding 'THK1' distance on 'pt's X coordinate and Y coordinate
(command "_.pline" pt pt_legXaxis ipt_legXaxis ipt ipt_legYaxis pt_legYaxis "c") ; invoke polyline command and order the point arguments to shape an outline
); progn
(alert "User interrupted an input")
); if
(princ)
); defun C:BAA Grrr1337提供了一个很好的解决方案
如果需要,您可以更改输入
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter values " "1st leg Len " 10 9 "6" "2nd leg len" 10 9 "6" "Thickness " 10 9 "1" )))
这个命令确实很神奇,我从检查每条线的作用中学到了很多,但我想知道是否有一种简单的方法来合并角度(正负90度)和角度外侧的圆角。我希望现在开始合并,以便以后我可以根据用户的输入进行更改。
非常感谢您的帮助和指导。 你有你的“常规”点来描述形状,对于这样的重新计算,你可能需要一些点旋转和/或点反射子功能。
以下是来自快速Google搜索的几个链接:
旋转点列表
如何计算镜像点
对于我个人来说,要执行此类任务,我使用Lee Mac的Matrix变换函数(因为我不擅长数学):
矩阵变换函数
您的下一个目标是如何将它们合并到您的代码中,并决定使用哪种用户输入来绘制旋转/镜像形状。
也许输入长度的-ve值可以使用GRRR码反转“L ”,但是需要改变几个值。如果Grrr不做第一,我会想一想。
找到时间玩了一把,很抱歉Grrr迷失在pt名称中,接受负距离。
; Sample chart:
; Original code by Grrr
; Modified by Alanh to do 4 directions
; pt2pt3
; ||
; ||
; ||
; || pt4
; ||___________ pt5
; pt1 |________________ pt6
;
;
(defun C:BAA ( / oldsnap pt1 LG1 LG2 THK1 l1 l2 l3 l4 pt1 pt2 pt3 pt4 pt5 pt6) ; always localise your variables
(defun l1 ( / )
(setq pt2 (mapcar '+ pt1 (list 0.0 LG1 0.0))) ; calculate the vertical leg by adding 'LG1' distance to 'pt's Y coordinate
(setq pt3 (mapcar '+ pt2 (list THK1 0.0 0.0))) ; calculate the inner top vertex by adding 'THK1' distance on 'ipt_legYaxis' s X coordinate
(setq pt4 (mapcar '+ pt1 (list THK1 THK1 0.0))) ; calculate the inner intersection by adding 'THK1' distance on 'pt's X coordinate and Y coordinate
(setq pt6 (mapcar '+ pt1 (list LG2 0.0 0.0))) ; calculate the horizontal leg by adding 'LG2' distance to 'pt's X coordinate
(setq pt5 (mapcar '+ pt6 (list 0.0 THK1 0.0))) ; calculate the inner bottom vertex by adding 'THK1' distance on 'ipt_legXaxis' s Y coordinate
(command "_.pline" pt1 pt2 pt3 pt4 pt5 pt6"c")
)
(defun l2 ( / )
(setq pt2 (mapcar '+ pt1 (list 0.0 LG1 0.0))) ; calculate the vertical leg by adding 'LG1' distance to 'pt's Y coordinate
(setq pt3 (mapcar '+ pt2 (list THK1 0.0 0.0))) ; calculate the inner top vertex by adding 'THK1' distance on 'ipt_legYaxis' s X coordinate
(setq pt4 (mapcar '+ pt1 (list THK1 (- THK1) 0.0))) ; calculate the inner intersection by adding 'THK1' distance on 'pt's X coordinate and Y coordinate
(setq pt6 (mapcar '+ pt1 (list LG2 0.0 0.0))) ; calculate the horizontal leg by adding 'LG2' distance to 'pt's X coordinate
(setq pt5 (mapcar '+ pt6 (list 0.0 (- THK1) 0.0))) ; calculate the inner bottom vertex by adding 'THK1' distance on 'ipt_legXaxis' s Y coordinate
(command "_.pline" pt1 pt2 pt3 pt4 pt5 pt6"c")
)
(defun l3 ( / )
(setq pt2 (mapcar '+ pt1 (list 0.0 LG1 0.0))) ; calculate the vertical leg by adding 'LG1' distance to 'pt's Y coordinate
(setq pt3 (mapcar '+ pt2 (list (- THK1) 0.0 0.0))) ; calculate the inner top vertex by adding 'THK1' distance on 'ipt_legYaxis' s X coordinate
(setq pt4 (mapcar '+ pt1 (list (- THK1) THK1 0.0))) ; calculate the inner intersection by adding 'THK1' distance on 'pt's X coordinate and Y coordinate
(setq pt6 (mapcar '+ pt1 (list LG2 0.0 0.0))) ; calculate the horizontal leg by adding 'LG2' distance to 'pt's X coordinate
(setq pt5 (mapcar '+ pt6 (list 0.0 THK1 0.0))) ; calculate the inner bottom vertex by adding 'THK1' distance on 'ipt_legXaxis' s Y coordinate
(command "_.pline" pt1 pt2 pt3 pt4 pt5 pt6"c")
)
(defun l4 (/ )
(setq pt2 (mapcar '+ pt1 (list 0.0 LG1 0.0))) ; calculate the vertical leg by adding 'LG1' distance to 'pt's Y coordinate
(setq pt3 (mapcar '+ pt2 (list (- THK1) 0.0 0.0))) ; calculate the inner top vertex by adding 'THK1' distance on 'ipt_legYaxis' s X coordinate
(setq pt4 (mapcar '+ pt1 (list (- THK1) (- THK1) 0.0))) ; calculate the inner intersection by adding 'THK1' distance on 'pt's X coordinate and Y coordinate
(setq pt6 (mapcar '+ pt1 (list LG2 0.0 0.0))) ; calculate the horizontal leg by adding 'LG2' distance to 'pt's X coordinate
(setq pt5 (mapcar '+ pt6 (list 0.0 (- THK1) 0.0))) ; calculate the inner bottom vertex by adding 'THK1' distance on 'ipt_legXaxis' s Y coordinate
(command "_.pline" pt1 pt2 pt3 pt4 pt5 pt6"c")
)
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(if (= (setqpt1 (getpoint "Choose a starting point")) nil)
(alert "User interrupted an input")
(progn
(setq ans (AH:getvalsm (list "Enter values " "Height" 6 5 "100" "Length " 6 5 "150" "Thick " 6 5 "10" )))
(setq LG1 (atof (nth 0 ans)) lG2 (atof (nth 1 ans)) THK1 (atof (nth 2 ans)))
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(cond
((and (> lg1 0.0)(> LG2 0.0))(L1))
((and ( LG2 0.0))(L2))
((and (> lg1 0.0)((defun C:BAA ( / pt LG1 LG2 THK1 pty ptx ipty iptx ipt dtr) ; Localizes the variables.
(setq CL (getvar "clayer")); Gets the current layer.
(command "layer" "m" "0" "c" 4 "" "l" "continuous" "" nil); Creates and sets layer 0.
(setq lm (getvar "limcheck")); Gets the current limit setting.
(setvar "limcheck" 0); Sets limits to 0 or off.
(defun dtr (x); Defines the degrees to radians. Remember to change it back.
(* pi (/ x 180.0)); Angle divided by 180, then total is multiplied by Pi.
); Closes Rad function.
(if
(and
(setq pt (getpoint "Please choose a start?")); Bottom left starting point of leg.
(setq LG1 (getreal "Please enter the 1st leg length?")); Vertical leg length.
(setq LG2 (getreal "Please enter the 2nd leg length?")); horizontal leg length.
(setq THK1 (getreal "How thick is the member?")); Thickness of the angle member.
); Closes and
(progn ; code block that processes the inputs
(setq pty (polar '+ pt (dtr 0.0 LG1 0.0))) ; Outside of vertical leg.
(setq ptx (polar '+ pt (dtr LG2 0.0 0.0))) ; Outside of horizontal leg.
(setq ipty (polar '+ pty (dtr THK1 0.0 0.0))) ; Inside of vertical leg.
(setq iptx (polar '+ ptx (dtr 0.0 THK1 0.0))) ; Inside horizontal leg.
(setq ipt (polar '+ pt (dtr THK1 THK1 0.0))) ; Inside intersection.
(command "pline" pt ptx iptx ipt ipty pty "c") ; Polyline to make the angle.
); Closes progn
); Closed if
(command "layer" "s" cl ""); To set layer back to original.
(setvar "limcheck" lm); To reset limit to starting limit.
); Closes defun 您当前代码的问题是您试图向“dtr”函数传递太多参数。
小提示,有些有简单的标准约定(它们可能看起来很小,但以后会对您有帮助)。
1。用“;”注释函数结尾;_
"字符串。
2。你可以排列你的行内注释以便于阅读(如果你使用文本编辑器并且可以控制它,我倾向于使用第57列)。
3。我在我的评论前加一个破折号,这样我就可以知道新的评论(句子/陈述)从哪里开始。
;; -X- This code does not work -X-
(defun C:BAA ( / pt LG1 LG2 THK1 pty ptx ipty iptx ipt dtr) ; -Localizes the variables.
(setq CL (getvar "clayer")) ; -Gets the current layer.
(command "layer" "m" "0" "c" 4 "" "l" "continuous" "" nil); -Creates and sets layer 0.
(setq lm (getvar "limcheck")) ; -Gets the current limit setting.
(setvar "limcheck" 0) ; -Sets limits to 0 or off.
(defun dtr (x) ; -Defines the degrees to radians. Remember
;to change it back.
(* pi (/ x 180.0)) ; -Angle divided by 180, then total
;is multiplied by Pi.
);_ defun
(if
(and
(setq pt (getpoint "Please choose a start?")) ; -Bottom left starting point of leg.
(setq LG1 (getreal "Please enter the 1st leg length?")); -Vertical leg length.
(setq LG2 (getreal "Please enter the 2nd leg length?")); -Horizontal leg length.
(setq THK1 (getreal "How thick is the member?")); -Thickness of the angle member.
);_ and
(progn ; -code block that processes the inputs
(setq pty (polar '+ pt (dtr 0.0 LG1 0.0))) ; -Outside of vertical leg.
(setq ptx (polar '+ pt (dtr LG2 0.0 0.0))) ; -Outside of horizontal leg.
(setq ipty (polar '+ pty (dtr THK1 0.0 0.0))) ; -Inside of vertical leg.
(setq iptx (polar '+ ptx (dtr 0.0 THK1 0.0))) ; -Inside horizontal leg.
(setq ipt (polar '+ pt (dtr THK1 THK1 0.0))) ; -Inside intersection.
(command "pline" pt ptx iptx ipt ipty pty "c") ; -Polyline to make the angle.
);_ progn
);_ if
(command "layer" "s" cl "") ; -To set layer back to original.
(setvar "limcheck" lm) ; -To reset limit to starting limit.
);_ defun
你看过我的第6篇文章中的所有代码了吗?它是全4方向的“L”。只需确保多个Getvals。lsp位于support path或Appload add to Startup Suite中,它在启动时加载。 有没有一个好的方法可以让它不需要“多GETVALS”LISP就能工作?
页:
[1]
2