乐筑天下

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

[编程交流] 交叉要素线Lisp rou

[复制链接]

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-5 16:51:26 | 显示全部楼层
For those interested, there's also a newly exposed Feature Line API:
 
http://www.theswamp.org/index.php?topic=49908.0
回复

使用道具 举报

95

主题

477

帖子

383

银币

后起之秀

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

铜币
475
发表于 2022-7-5 16:54:37 | 显示全部楼层
Hippe013 this code is awesome! It is going to be a sweet one for me to study to learn some new coding techniques. My home computer doesn't have autocad on it unfortunately, so I'll have to wait until Monday to test it out unfortunately. Thank you for coming up with this code, it is much better way of doing it than my initial thought.
回复

使用道具 举报

20

主题

338

帖子

323

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 2022-7-5 16:59:47 | 显示全部楼层
Broncos15 - Cheers! I hope it works for you!
 
BlackBox - Great link! I've been trying to move over to vb.net. I'm just finding the learning curve to be rather steep. I can see that using .net has much more access to properties and methods. Though at this point I'm very much a noob when it comes to vb.net. Lots to learn!
 
regards,
 
hippe013
回复

使用道具 举报

95

主题

477

帖子

383

银币

后起之秀

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

铜币
475
发表于 2022-7-5 17:02:58 | 显示全部楼层
Hippe013, after glancing through the code more I think I have a solution that would work well for assigning elevations, especially for typical work flow. The user would create a new feature line and assign elevations from the surface of there choice (ie FG). Then they could run this flint code choosing a feature line that is already on the surface. My thinking is that a prompt would be most useful that allows the user to choose what surface to assign elevations to the newly created elevation points (most often they would choose the FG surface). They could then add the new feature line to the surface after this. I think by having a prompt that allows the user to choose what surface to assign elevations to the elevation points would solve the randomness issue. The randomness issue isn't a huge issue though if you think my method is to complex because it would be easy to regrade those few elevation points after running flint. Thanks again for creating this, I really appreciate it!
回复

使用道具 举报

20

主题

338

帖子

323

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 2022-7-5 17:06:49 | 显示全部楼层
Yes, The possibilities are endless as far as prompting for the elevations. You could have it automatically extract the elevations from a surface using the FindElevatioAtXY method of the tin surface object. Or you could have the user enter elevations individually or a default elevation for all of them. This currently just grabs whatever elevation is found through the IntersectWith method. This way if there are a lot of intersections then they are added quickly without user interaction. You could implement some command settings that read and write to the cfg file using getcfg and setcfg. This is an easy way for the command to remember settings that the user has set. I personally would leave this as is  (I plan to use this at work) and just regrade as necessary. I am not a fan of the implied intersections as I would rather have an ElevationPoint there for grading through. Feel free to manipulate the code to fit your needs. I am happy to have provided you with a starting point.
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-5 17:08:27 | 显示全部楼层
 
Not that many moons ago, I didn't even know what a LISP Defun was; flash forward to my decision to skip VBA and jump from Visual LISP to .NET, and I made a similar choice - to start learning VB.
 
It was my experience that this was actually a hindrance to my learning .NET, which contradicted my basis for starting with VB- that it was very similar syntactically to Visual LISP (ActiveX COM) - something that distracted me by looking for similarities in APIs rather than learning the more distinctive aspects that make .NET what it is.
 
That led me to ultimately drop VB altogether, and start teaching myself C#... And 1800 page Andrew Troelsen book later, 100% of my .NET coding is in C# - custom .NET plugins, custom LispFunction Method plugins (to expand LISP API), VSTO/Windows apps, and WPF Browser apps, etc - and I couldn't be happier with making the leap.
 
This has made me not only better at my daily CAD Production, but also a better CAD/Network admin.
 
Cheers
回复

使用道具 举报

95

主题

477

帖子

383

银币

后起之秀

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

铜币
475
发表于 2022-7-5 17:12:37 | 显示全部楼层
Hippe013, After testing the code out at my office, I have to say I don't think there is a need to add in any more prompts. It works really well and I know I am going to use it a lot while grading. The only thing that I noticed is that the code has issues when there is already an elevation point on the line. When there is already an elevation point at an intersection, it will add in another elevation point on top of the first one. This could cause issues if the user uses flint on the same feature line multiple times (like when more feature lines are added in at a later date). I tried fixing this by changing the insertion from an elevation point to a PI (because CAD doesn't allow you to add multiple PI's on top of each other for the same object), the issue then is that if there is just if there are multiple crossings, but a PI at just one of them, then the code won't run at all. Thanks again for making this code, it will really expedite grading for me and I know many other people that stumble across this post! 
 
My code below with PI's, but I am still having issues with it running when there is already a PI at one of the crossings:
  1. (defun c:FEATURELINECROSSING (/ fl site fls p-count sa catch n proc) (setq ss (ssget "_+.:E:S" '((0 . "AECC_FEATURE_LINE")))) (if ss   (progn     (setq fl (vlax-ename->vla-object (ssname ss 0)))     (setq site (FL:FL->site fl))     (setq fls (vlax-get-property site 'Featurelines))     (setq p-count 0)     (vlax-for f fls(if (not (equal f fl))  (progn    (setq sa    (vlax-variant-value      (vlax-invoke-method fl 'IntersectWith f acExtendNone)    )    )    (setq catch    (vl-catch-all-apply 'vlax-safearray->list (list sa))    )    (if (not (vl-catch-all-error-p catch))      (progn (setq catch (fl:list->pntlist catch)) (setq n 0) (repeat (length catch)   (setq p (nth n catch))   (if (not (member p proc))     (progn    ;Use 2 for Elevation Point - Use 1 for PI       (vlax-invoke-method  fl  'InsertFeaturePoint  (vlax-3d-point p)  1       )       (vlax-invoke-method  f  'InsertFeaturePoint  (vlax-3d-point p)  1       )       (fl:drx p 1)       (setq proc (append proc (list p)))       (setq p-count (+ p-count 1))     )   )   (setq n (+ n 1)) )      )      (progn)    )  ))     )     (princ(strcat "\nInserted " (itoa p-count) " PI's.")     )   )   (princ "\nNothing was Selected.") ) (princ))(defun FL:Site->FL-ID-List (site / fls cnt ret n li) (setq fls (vlax-get-property site 'Featurelines)) (setq cnt (vlax-get-property fls 'Count)) (if (= cnt 0)   (setq ret nil)   (progn     (setq n 0)     (repeat cnt(setq  li (append       li       (list (vlax-get-property (vla-item fls n) 'ObjectID))     ))(setq n (1+ n))     )     (setq ret li)   ) ) ret)(defun FL:List->pntlist (li / newli) (setq n 0) (repeat (/ (length li) 3)   (setq newli (append newli  (list (list (nth n li)       (nth (+ n 1) li)       (nth (+ n 2) li)        )  ) )   )   (setq n (+ n 3)) ) newli)(defun FL:FL->Site (fl / cvlapp cvlad sites ret n site objid-list) (setq cvlapp (vlax-get-property fl 'application)) (setq cvlad (vlax-get-property cvlapp 'ActiveDocument)) (setq sites (vlax-get-property cvlad 'Sites)) (setq ret nil) (setq n 0) (repeat (vlax-get-property sites 'Count)   (setq site (vla-item sites n))   (setq objid-list (FL:Site->FL-ID-List site))   (if (member (vlax-get-property fl 'ObjectID) objid-list)     (setq ret site)   )   (setq n (1+ n)) ) ret)(defun FL:drx (ctr clr / cor1 cor2 cor3 cor4 vs xs) (setq vs (getvar "viewsize")) (setq xs (/ vs 40)) (setq cor1 (polar ctr (* pi 0.25) xs)) (setq cor2 (polar ctr (* pi 0.75) xs)) (setq cor3 (polar ctr (* pi 1.25) xs)) (setq cor4 (polar ctr (* pi 1.75) xs)) (grdraw ctr cor1 clr 0) (grdraw ctr cor2 clr 0) (grdraw ctr cor3 clr 0) (grdraw ctr cor4 clr 0))
回复

使用道具 举报

95

主题

477

帖子

383

银币

后起之秀

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

铜币
475
发表于 2022-7-5 17:16:23 | 显示全部楼层
After messing around with the code this morning, I am still having issues with having it insert an elevation point where one already exists. I know that I need another if statement at this portion of the code:
  1. (if (not (member p proc))            (progn       (vlax-invoke-method fl 'InsertFeaturePoint (vlax-3d-point p) 2)              (vlax-invoke-method f 'InsertFeaturePoint (vlax-3d-point p) 2)
However, I have searched and can't find how to have the if statement test whether an elevation point exists. Does anyone know what the if statement would need to look like to test and see if an elevation point exists, and if it doesn't then to run the above code?
回复

使用道具 举报

20

主题

338

帖子

323

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 2022-7-5 17:17:29 | 显示全部楼层
Broncos15,
 
I just saw your reply. I guess I never thought about what would happen if it was run more than once or if there was already an elevation point. I will take another look at my code and add in a test expression that if an elevation point or PI exists in the spot then skip inserting that point. It may take me a couple days to sit down and look at it.
 
regards,
 
hippe013
回复

使用道具 举报

95

主题

477

帖子

383

银币

后起之秀

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

铜币
475
发表于 2022-7-5 17:20:13 | 显示全部楼层
Hippe013, thank you so much for getting back to me! I would love to see what that test expression would look like because I have messed around with it for a long time and I can't seem to think of how to write it. Unfortunately, I have just started learning Visual Lisp so I am pretty unfamiliar with all of the vla functions, which is why I am trying to learn them and see examples. Thanks again for the help with this code, it is really useful and has been cool to look through and learn more about. Also, I was curious after looking through all of the code. Why is (vl-load-com) not needed anywhere in the code if it makes use of Visual Lisp functions?
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-8-20 21:48 , Processed in 0.379858 second(s), 71 queries .

© 2020-2025 乐筑天下

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