乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: prodromosm

[编程交流] Level lines -calculate height

[复制链接]

107

主题

615

帖子

575

银币

中流砥柱

Rank: 25

铜币
521
发表于 2022-7-6 02:33:52 | 显示全部楼层
Nice try but i think that the calculation is wrong. Can you do something for the second part.
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
211
发表于 2022-7-6 02:37:20 | 显示全部楼层
 
I see, show me the correct value if i select the middle of the line? 150.20?
 
I see why.i'm guessing ts a  TEXT alignment point/Insertion point issue. changing 10 to 11 is the quick fix.
 
Code at post #10 updated
回复

使用道具 举报

107

主题

615

帖子

575

银币

中流砥柱

Rank: 25

铜币
521
发表于 2022-7-6 02:39:56 | 显示全部楼层
With the yellow collor is your results. Some calculations are the same with mine but same other are difference.I add some red points to speak about specific position
contous2.dwg
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
211
发表于 2022-7-6 02:44:38 | 显示全部楼层
 
Update code at post # 10
回复

使用道具 举报

107

主题

615

帖子

575

银币

中流砥柱

Rank: 25

铜币
521
发表于 2022-7-6 02:45:20 | 显示全部楼层
nice job pBe thanx.The first part of my question is complete.....
Can you do something for the second part.
- select level lines (polilynes with angle of inclination) and calculate the beween elevetions
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
211
发表于 2022-7-6 02:49:15 | 显示全部楼层
 
Glad it works for you.
Wanted to get the feedback on item number 1 first, I'll post a code for number 2 later.
回复

使用道具 举报

2

主题

53

帖子

57

银币

初来乍到

Rank: 1

铜币
14
发表于 2022-7-6 02:52:55 | 显示全部楼层
that's really good, but can it be made for block attributes 'instead of / as well as' text?
 
thanks
 
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
211
发表于 2022-7-6 02:54:18 | 显示全部楼层
 
Yes it can be done, but what will be the reference for the distance? is it the block insertion point? [refer to second code at post # 10]
 
@prodromosm
 
Item number 2: based on your example. "elevation" between contor 1  and contour 2  you have 110.8, automating the process can be quite tricky . if i to write a code i will determine half the distance between contour lines which makes a dead even 110.00. and so on. Now if you add an option to indicate a "distance from" or divide the space by # then we can proceed to do that. IF you are wanting to pick a point between each contour at every interval, that will give the distance per level, is that how you wanted it to work for you?
回复

使用道具 举报

2

主题

53

帖子

57

银币

初来乍到

Rank: 1

铜币
14
发表于 2022-7-6 03:00:19 | 显示全部楼层
yes block insertion point
 
P
回复

使用道具 举报

GP_

8

主题

248

帖子

245

银币

初来乍到

Rank: 1

铜币
42
发表于 2022-7-6 03:00:53 | 显示全部楼层
Good code, pBe.
 
 
This is my attempt for item number 2.
Does not always work.
 
Here it works.
 

 
 
Here it does not work.
 

 
 
  1. (defun c:test ( / p1 p2 d sel LEV LEV_F LEV_L TT)   (if       (and           (setq p1 (getpoint "\nSelect Level Lines, first fence point:"))           (setq p2 (getpoint p1 "\nSpecify endpoint of line:"))                (setq d (distance p1 p2))           (if (setq sel (ssget "_F" (list p1 p2) '((0 . "LWPOLYLINE"))))               (progn                   (repeat (setq n (sslength sel))                       (setq LEV (cons (ssname sel (setq n (1- n))) LEV))                   )                   (setq LEV (reverse LEV))               )           )           (setq LEV_F (car LEV))           (setq LEV_L (last LEV))           (if               (>                   (cdr (assoc 38 (entget LEV_L)))                   (cdr (assoc 38 (entget LEV_F)))               )               (setq segno -)               (setq segno +)                           )       )       (progn           (setq TT               (vlax-ename->vla-object                   (entmakex                       (list                           (cons 0 "TEXT")                           (cons 7 (getvar "textstyle"))                           (cons 10 p2)                           (cons 11 p2)                                                            (cons 40 2.5)                           (cons 1 "")                           (cons 73 2)                           (cons 72 1)                           (cons 50 0)                       )                   )               )           )           (princ "\nText position: ")           (while (= (car (setq pt (grread T 12 0))) 5)               (vla-put-TextAlignmentPoint TT (vlax-3d-point (cadr pt)))               (vla-put-TextString TT (location))           )           (if (= (vla-get-TextString TT) "OUT") (vla-delete TT))       )   )   (prompt "\n ")(prompt "\n ")   (princ));***************************************************************************(defun location ( / pa ang pb pc e1 e2 elev_a elev_b diff p_1 p_2 elev+ elev)   (setq pa (cadr pt))   (setq ang            (angle                (vlax-curve-getClosestPointTo LEV_F pa)                (vlax-curve-getClosestPointTo LEV_L pa)            )   )   (setq pb (polar pa ang d))   (setq pc (polar pa (- ang pi) d))   (if       (and           (setq e1 (ssget "_F" (list pa pb) '((0 . "LWPOLYLINE"))))           (setq e1 (ssname e1 0))           (setq e2 (ssget "_F" (list pa pc) '((0 . "LWPOLYLINE"))))           (setq e2 (ssname e2  0))       )       (progn           (setq elev_a (cdr (assoc 38 (entget e1))))           (setq elev_b (cdr (assoc 38 (entget e2))))           (setq diff (abs (- elev_a elev_b)))              (setq p_1 (LEV_inters pa pb (pl_coord e1)))           (setq p_2 (LEV_inters pa pc (pl_coord e2)))                       (if (and p_1 p_2)               (setq elev+ (/ (* (distance p_1 pa) diff) (distance p_1 p_2))                     elev (rtos (segno elev_a elev+))               )           )       )       "OUT"   ));***************************************************************************(defun LEV_inters (:p1 :p2 vPL / p_int *p*)   (mapcar       '(lambda (a b)            (setq *p*                     (inters                         (list (car a) (cadr a))                         (list (car b) (cadr b))                         :p1                         :p2                     )            )            (if *p* (setq p_int *p*))        )       vPL  (cdr vPL)   )   p_int);***************************************************************************(defun pl_coord (# / p m)   (setq p (if (vlax-curve-IsClosed #)               (fix (vlax-curve-getEndParam #))               (1+ (fix (vlax-curve-getEndParam #)))           )   )   (while (/= 0 p)       (setq m (cons (vlax-curve-getPointAtParam # (setq p (1- p))) m))   ))
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-10 22:31 , Processed in 0.620587 second(s), 82 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表