How to combine 2 entities as 1 in Autocad .net

不羁的心 提交于 2019-12-23 04:49:32

问题


I'm making an autocad plugin and i want to create a new entity that is a combination of a line and the text.If i select the line the text is selected and backwords when i delete the line delete the text etc etc.How to treat them as one object referencing eachother?Is this possible?


回答1:


I recommend using groups. Below is a link on how to access groups, I'm sure that site has more information on creating groups.

Users can control whether objects are selected with the group based on the system variable, PICKSTYLE. you can use ctrl+ h to toggle the PICKSTYLE value.

http://adndevblog.typepad.com/autocad/2012/04/how-to-detect-whether-entity-is-belong-to-any-group-or-not.html




回答2:


Another option - though it doesn't answer your question - and this is something for you to think about: is to create a new block which consists of the line and some text. The line can be an entity in your block, and the text can be a tag string value. the tag can be called "line_information".




回答3:


I know this might be abit too late but there is a better more flexible way to do this, although it's not actually combining the two entities but rather more of a visual effect. It's called using Overrules. Basically you change the way the entity is displayed. So instead of displaying a line, you can display a circle, or in your case display a text and a line. Overruling is a very powerful tool, you can not only change how the entity looks but also add grips, remove grips, change how entity is highlighted or highlight other entities when your entity is highlighted, override some of the entity methods like erase and much more.

Best place to start from is Kean Walmsley's "Through the Interface" blog. And here is a link to this blog related to what you want to achieve

http://through-the-interface.typepad.com/through_the_interface/2009/08/a-simple-overrule-to-change-the-way-autocad-lines-are-displayed-using-net.html



来源:https://stackoverflow.com/questions/17721346/how-to-combine-2-entities-as-1-in-autocad-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!