查找轴承lisp。(贝金纳)
大家好,第一个帖子,但希望你能善待我,我已经潜伏了一段时间,但这是我第一次需要发布!
我正在学习Lisp例程,但还没有时间!我想要一个非常基本的,我希望。
我需要找到两点点击之间的方位。
因此,基本上,单击一次以设置原点,然后在目标位置进行第二次单击,然后给出输出,表示第一个点的X、Y、Z,以及第二次单击的弧度方向。
有没有一个基本的图坦卡门来制作这样的东西?或者,如果有人能举一个例子并发表评论,那就太好了。
干杯
布林
我们可以假设您希望零引用是直接的还是传统的“北”吗?我们可以问一下“为什么弧度是轴承”? 您好,谢谢您的回复,是的,北方应该是笔直的,它需要是弧度,因为这些数据将用于另一个只接受弧度的程序。如果我可以像上面那样获得数据,那么我可以在程序员文件编辑器中运行宏,将其转换为正确的格式。基本上是眼点加上方位,然后另一个程序知道“看”的方向
我假设弧度不是问题,因为我可以很快从CAD中获得这些信息,但它有点重复。 嗨,布林,
我不确定这是否能让你开始,我希望能。我写它是为了得到水平距离和斜率,以及坐标和方向角。它使用了一个警报函数,而您可能希望去掉它,只使用变量。它可能仍然需要一些错误捕捉,但由于我也是一个新手,我不知道如何做所有的“这些东西”。
(defun c:hzdplus (/ angtype oldir factp actp sdist hdist mang Nchar1 Nchar2 Echar1 Echar2 Zchar1 Zchar2)
(setq angtype (getvar "AUNITS")) ;;; Get current user Units
(setq oldir (getvar "ANGDIR")) ;;;; Get current user Direction
(setq factp (getpoint "\nPick Point 1: ") ;;; Store Point 1
actp(getpoint factp "\nPick Point 2: ") ;;; Store Point 2
)
(setq sdist (rtos (distance factp actp)2 3));;; Get slope Distance and store as string
(setq coor1y (cadr factp) ;;; Get Northing of Point 1
coor1x (car factp) ;;; Get Easting of Point 1
coor1z (caddr factp) ;;; Get Height of Point 1
)
(setq afact (list coor1x coor1y 0)) ;;; Store Easting and Northing with Height as 0 (for horizontal distance) of Point 1
(setq coor2y (cadr actp) ;;; Get Northing of Point 2
coor2x (car actp) ;;; Get Easting of Point 2
coor2z (caddr actp) ;;; Get Height of Point 2
)
(setq aact (list coor2x coor2y 0)) ;;; Store Easting and Northing with Height as 0 (for horizontal distance) of Point 2
(setq Nchar1 (rtos coor1y 2 3) ;;; Store North coordinate of Point 1 as String in decimal format
Echar1 (rtos coor1x 2 3) ;;; Store East coordinate of Point 1 as String in decimal format
Zchar1 (rtos coor1z 2 3) ;;; Store Height coordinate of Point 1 as String in decimal format
)
(setq Nchar2 (rtos coor2y 2 3) ;;; Store North coordinate of Point 2 as String in decimal format
Echar2 (rtos coor2x 2 3) ;;; Store East coordinate of Point 2 as String in decimal format
Zchar2 (rtos coor2z 2 3) ;;; Store Height coordinate of Point 2 as String in decimal format
)
(if (< (strlen Nchar2) ;;; <---- From here, Just error trapping for formatting in alert box,
(setq Nchar2 (strcat "\t" Nchar2))) ;;; not totally correct but works for my coordinate system!
(if (< (strlen Echar2)
(setq Echar2 (strcat "\t" Echar2)))
(if (< (strlen Zchar2)
(setq Zchar2 (strcat "\t" Zchar2))) ;;; <---- To here
(setq mang (angle factp actp)) ;;; Get Angle in Radians
(cond ((= angtype 0) (setq mang (angtos mang 0 4))) ;;; <--- From here
((= angtype 1) (setq mang (angtos mang 1 4)))
((= angtype 2) (setq mang (angtos mang 2 4)))
((= angtype 3) (setq mang (angtos mang 3 4)))
((= angtype 4) (setq mang (angtos mang 4 4))));;; <---To here, Set angle to user Unit settings and convert to string
(setq hdist (rtos (distance afact aact) 2 3));;; Get horizontal distance from ht=0 point stored variable and convert to string
(alert (strcat "\n\ RESULT\t" ;;; Display the stuff
"\n"
"\n\Angle = " mang
"\n"
"\n\Slope Distance = " sdist
"\n"
"\n\Horizontal Distance = " hdist
"\n\n"
"\Point 1\t\tPoint 2"
"\n"
Nchar1
"\t"
Nchar2
"\n"
Echar1
"\t"
Echar2
"\n"
Zchar1
"\t"
Zchar2
)
)
(princ)
)
和
(setq hdist (rtos (distance afact aact) 2 3)); Get horizontal distance from ht=0 point stored variable and convert to string
~'J'~ 看看这个:
http://www.cadtutor.net/forum/showthread.php?t=42128 谢谢大家,这看起来像一个简单的Lisp程序,这是一个很好的开始,我开始学习!
好的,我已经到了其他程序“quirk”的底部,它给出了一个预期的xyz,然后也给出了0-1 0形式的旋转。每个图形给出了一个角度来旋转视图,在每个xyz平面上,加上-1告诉它顺时针或逆时针旋转。只要我将-1设置为+1,一个较大的数字将给出正确的激发。这对从事3D cad工作的人来说可能意义非凡?但这对我来说是全新的。。。要一次学会很多东西!为Alanjt干杯。我会张贴在你的线程以及。。。
Hi Scu,
Sorry, I don't know what is the bearing
but after I did run your code there are both distance
equal :
Slope distance = Horizontal distance
Is that right?
~'J'~
Ah.. I think if both points are the same height e.g. both Z = 0 then horizontal = slope as there is no slope. I changed this program from my first simple version cause I used initget 64 to ignore Z values but then I couldn't get the Slope from the picked points.
If this isn't the case and they have different heights then I'm not sure why?!! Let me know if this is the case. Although you might have a better go at figuring it out as I'm still new at Lisp.
oh and Bearing.. Angle or azimuth people call it different things but this program suppose to work in relation to your angle direction (angdir = 0 or 1, = anti-clockwise or clockwise) and angle base in _units/direction setup. So if you set base angle to North it will be the angle from north in either clockwise or anti clockwise direction. I work in the southern hemisphere with North being up and clockwise.. not normal for CAD! I think I notice if using Land Desktop too.. it stuffs up all my programs I don't know why..database maybe?
Also my question is, why when you type angbase at command line (showing 90d on my computer), it is different to the menu.. format/ units/ direction/ angle base North = 270d? Are they different system variables? Both point have the different heights...
Ok, as they said here, I need time to chew it
Will be back at tomorrow
~'J'~
页:
[1]
2