乐筑天下

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

[编程交流] Labeling polyline (elements fr

[复制链接]

4

主题

19

帖子

15

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 17:18:31 | 显示全部楼层 |阅读模式
Hello,
 
I'm working on sewer planning, so I have to label a ton of 2D polyline segments with its length, slope, pipe type (material), and pipe profile (radius in mm). All of these information's are stored in .dat file (text file, input file extension for AutoCAD module I'm using). Module is based on AutoCAD Map 2008, also I use Civil 3D 2010.
 
This is how it's supposed to look:

                               
登录/注册后可看大图

 
As you can see, above line segment is printed segment length with suffix "L=", under the segment is slope (in percentage) with suffix "i=" and prefix "%" and type material (PVC SN8).
 
I would format .dat file to contain only necessary data, and to be .txt off course.
Is it possible to do this in Civil 3D somehow, or it requires writing a LISP?
 
(I've attached cleaned .txt file. First column is segment length, second pipe material, third pipe radius (profile), and fourth is slope).
 
Any help is welcome. I'm loosing a lot of time on doing this by hand. I have less then 30 days to finish, so any hour saved is
significant.
 
Thank you
sewer_S6.txt
sewer_s6.dwg
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:24:05 | 显示全部楼层
Have you looked at CIV3d pipe styles ?
回复

使用道具 举报

4

主题

19

帖子

15

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 17:26:17 | 显示全部楼层
All of the modules for surveying and planing are in Map 3D 2008, so I'm using it in 9/10 cases. Civil 3D is mainly used for surveying tools (import/export points, creating surfaces, calculating volume...). I mentioned Civil, because I thought there is some Labeling tool to do this.
 
I've never used Pipe Network for planing. Also, (if I understood correctly) I need to do all the planning I have done so far, again using Pipe Network in order to be able to label the pipes the way I want?
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:29:15 | 显示全部楼层
Maybe I understand a bit more now. Take a pline co-ords lsp this will give all the pline vertices you can then read your dat file and draw the text at the correct location.
eg middle of pt2 pt3 and 3 below same angle as pt2-pt3. I would make a few defuns one for each part of the labelling. I dont have any code that matches a google for "label plines" may help find something that can be patched together quickly. I am in middle of a major project at moment so time is not something I have.
回复

使用道具 举报

4

主题

19

帖子

15

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 17:34:05 | 显示全部楼层
This morning, on my way to work, i got same idea. I think I have  a lisp for exporting vertices coord in txt file, somewhere. My idea was to create a lisp (lets call it printAbove) that requires several parameters to print text. For example: text alignment X, text alignment Y, angle, text, layer (or height, color, font). I could easily format my output file to contain these data. Then, use MULTIPLE function on printAbove. Same to do for printUnder. What do you think?
 
I have been searching for "label polylines", but could't find anything I can use. I appreciate your time you are taking each time to reply. Right now, I'm working on two projects, it takes more then 12 hours of my day, that is why I don't reply immediately, and I apologize for that.
 
I don't know AutoLISP, started to learn 2/y ago, but could'n manage to find time. I can read most of the code, and do some minor modifications.
 
Again, thank you for replies
 
Edit:
 
I have found that lisp for exporting vertices coord to txt file:
 
  1. (defun vert (/                 filterlist  vla-obj-list     lwlist         2dlist             ptlist         vlist1     vlist2         vlist3    ) (vl-load-com) (setq        filterlist   (make-filter)vla-obj-list (get-objects filterlist)lwlist             (nth 0 vla-obj-list)2dlist             (nth 1 vla-obj-list)ptlist             (nth 2 vla-obj-list)vlist1             nilvlist2             nilvlist3             nil ) ;_ end-of setq (if lwlist   (setq vlist1 (make-list lwlist 2)) ) ;_ end of if (if 2dlist   (setq vlist2 (make-list 2dlist 3)) ) ;_ end of if (if ptlist   (setq vlist3 (make-list ptlist 3)) ) ;_ end of if (write-text vlist1 vlist2 vlist3) (princ)) ;_ end of vert(defun make-list (p-list n / i vlist obj coords ca j x y z xy) (setq        i (- 1)vlist nil ) ;_ end of setq (repeat (length p-list)   (setq obj         (nth (setq i (1+ i)) p-list)  coords (vlax-get-property obj "coordinates")  ca         (vlax-variant-value coords)  j         (- 1)   ) ;_ end-of setq   (repeat (/ (length (vlax-safearray->list ca)) n)     (setq x (vlax-safearray-get-element ca (setq j (1+ j))))     (setq y (vlax-safearray-get-element ca (setq j (1+ j))))     (if (= n 2)(setq xy (list x y))(progn  (setq z (vlax-safearray-get-element ca (setq j (1+ j))))  (setq xy (list x y z))) ;_ end of progn     ) ;_ end of if     (setq vlist (append vlist (list xy)))   ) ;_ end-of repeat ) ;_ end-of repeat) ;_ end-of make-list(defun make-filter (/ filter) (setq        filter '((-4 . "")        ) ) ;_ end of setq) ;_ end of make-filter(defun get-objects (filter  /            ss            k            lwp-list            2dp-list            pt-list no-ent  obj            pl            2d            pt           ) (setq no-ent 1) (while no-ent   (setq ss           (ssget filter)  k           (- 1)  lwp-list nil  2dp-list nil  pt-list  nil  obj           nil  pl           "AcDbPolyline"  2d           "AcDb2dPolyline"  pt           "AcDbPoint"   ) ;_ end-of setq   (if        ss     (progn(setq no-ent nil)(repeat        (sslength ss)  (setq        ent (ssname ss (setq k (1+ k)))        obj (vlax-ename->vla-object ent)  ) ;_ end-of setq  (cond    ((= (vlax-get-property obj "ObjectName") pl)     (setq lwp-list (append lwp-list (list obj)))    )    ((= (vlax-get-property obj "ObjectName") 2d)     (setq 2dp-list (append 2dp-list (list obj)))    )    ((= (vlax-get-property obj "ObjectName") pt)     (setq pt-list (append pt-list (list obj)))    )  ) ;_ end-of cond) ;_ end-of repeat     ) ;_ end-of progn     (prompt "\nNo polylines or points selected, try again.")   ) ;_ end-of if ) ;_ end-of while (list lwp-list 2dp-list pt-list)) ;_ end-of get-objects(defun write-text (vl1 vl2 vl3) (setq        fn (getfiled "Text File" "" "txt" 1))  (setq f (close (open fn "w"))) (setq msg "Points from LW-Polylines") (do-points fn vl1 msg 2) (setq msg "Points from 2d-Polylines") (do-points fn vl2 msg 3) (setq msg "Points from Point entities") (do-points fn vl3 msg 3) (princ)) ;_ end of write-text(defun do-points (fn vl msg n) (setq f (open fn "a")) (write-line msg f) (write-line "  x,  y,  z" f) (write-line "" f) (foreach point vl   (setq x (nth 0 point)  y (nth 1 point)   ) ;_ end of setq   (if        (= n 2)     (setq str (strcat (rtos x) "," (rtos y)))     (progn(setq z (nth 2 point))(setq str (strcat (rtos x) "," (rtos y) "," (rtos z)))     ) ;_ end of progn   ) ;_ end of if   (write-line str f) ) ;_ end of foreach (setq f (close f)) (princ)) ;_ end of defun(defun c:pts () (vert) (princ)) ;_ end-of defun(prompt "PLIST.LSP by Tony Hotchkiss - enter PTS to start ")
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:36:59 | 显示全部楼层
Bit long winded, the co-ords are saved as a list in the variable co-ordsxy.
 
 
sample result of a 2d pline 3 lines
Command: !co-ordsxy
((316.186 303.015) (433.333 303.015) (433.333 371.628) (275.147 371.628))
 
 
 
  1. ; pline co-ords example; By Alan H(defun getcoords (ent) (vlax-safearray->list   (vlax-variant-value     (vlax-get-property   (vlax-ename->vla-object ent)   "Coordinates"     )   ) ))(defun co-ords2xy (); convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z(setq len (length co-ords))(setq numb (/ len 2)) ; even and odd check required(setq I 0)(repeat numb(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) )); odd (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) ))(setq co-ordsxy (cons xy co-ordsxy))(setq I (+ I 2)))); program starts here(setq co-ords (getcoords (car (entsel "\nplease pick pline"))))(co-ords2xy) ; list of 2d points making pline
回复

使用道具 举报

4

主题

19

帖子

15

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 17:39:29 | 显示全部楼层
Something isn't working properly. As you can see in screenshot, x and y are not grouped in parenthesis in every case. Sometimes there are only X coord, and Y coord is 0.0, and vice versa.
 

                               
登录/注册后可看大图

 
(4.97316e+006 0.0) (0.0 6.41379e+006) should probably be: (6.41379e+006 4.97316e+006)
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 17:42:42 | 显示全部楼层
Hi,
 
Firstly please modify your post #5 and add CODE TAGS as shown in THIS LINK
 
Secondly I will not promise that I can help you as best as you looking forward but I will do my best if you can explain your issues very clearly.
 
So can you explain what is the purpose of the .txt file attached in the first post? Because I can not see anything in common between the txt fie and the attached drawing.
 
Should the user be asked to select a .txt file then write these data into attributed block as shown in the drawing ?
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:44:30 | 显示全部楼层
kevin sorry your correct the output is x y x y x y or if 3d x y z x y z x y z
 
I agree with Tharwat your dwg does not really reflect what your saying I think what your implying is to work out all the invert levels and label.
回复

使用道具 举报

4

主题

19

帖子

15

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 17:50:09 | 显示全部楼层
Tharwat
 
text file I' attached is "refined" .dat file (.dat file is file dreated for importing in AutoCAD, then used to draw pipe profile view). I made mistake defining column content. Firs column ist length of segment, second AND third are pipe material, fourth is pipe profile, and fifth is slope. Only connection between txt and dwg is segment length, so my idea was to export pline vertices coord in txt, create file for print (in Excel for example, one row to look like: text alignment X, text alignment Y, angle, text, layer (or height, color, font)). Also, profile view (you can see it in UPR Layout of attached dwg in this post) contains information on pipe (2 red parallel lines in "niveleta" Layer represents pipe).
 
I have deleted attributed block, as they are irrelevant to this matter. To simplify problem: I need to label 2D pline with its length and informations I have in text file. On this project I need do this for 50-60 kilometers of primary Network, hundreds of secondary, and hundreds of tertiary. So it requires a lot of time to be done by hand.
PIPELINE_example6.dwg
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 08:18 , Processed in 1.024086 second(s), 73 queries .

© 2020-2025 乐筑天下

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