How to combine 2 entities as 1 in Autocad .net

2019-06-14 05:26发布

enter image description here

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?

3条回答
倾城 Initia
2楼-- · 2019-06-14 06:07

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

查看更多
再贱就再见
3楼-- · 2019-06-14 06:10

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

查看更多
叛逆
4楼-- · 2019-06-14 06:27

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".

查看更多
登录 后发表回答