31
.NET / How to create Link between objects?
« Last post by Augusto on June 01, 2023, 10:18:08 PM »Hello, everyone!
I decided to step out of my comfort zone and put autoLisp aside for a while. This is my first code in C# for AutoCAD.
The goal of this code is to initially create a representation of a flexible tube. I would really like to link the block I'm creating with the polyline and, depending on the event, recreate the block while maintaining its initial creation characteristics.
Unfortunately, after many attempts, I couldn't store the block information within the polyline. In the commented sections of the code, I can create a dictionary and assign it to the polyline, but after the modification (stretch), the dictionary disappears, and I can't access it to obtain the ObjectId of the block and then perform the deletion.
Since I don't have previous experience with the API, I imagine my code is not very good, and I'm also not following any best practices in AutoCAD .NET development, which results in duplicated code and other oddities. In the future, I will strive to produce something better, but for now, I'm just trying to learn and make it work.
I would greatly appreciate it if you could assist me with object linking and perhaps provide tips on best practices in AutoCAD .NET development.
I'm using autoCAD 2020 and visual studio 2019.
I've been looking at some code on the through-the-interface page. This would be the best scenario, where the links are maintained and loaded when loading the drawing, but I think I'm not ready to implement something of such complexity yet.
https://through-the-interface.typepad.com/through_the_interface/2006/11/linking_circles_1.html
I haven't worked with the collisions and other things that must be done yet, so the code produces bad results on very steep curves. I intend to put the minimum bend radius based on the diameter and material properties.
The project is attached, as well as the dwg file in 2010 format.
Thanks in advance for any help.
Best regards, Luís Augusto.
I decided to step out of my comfort zone and put autoLisp aside for a while. This is my first code in C# for AutoCAD.
The goal of this code is to initially create a representation of a flexible tube. I would really like to link the block I'm creating with the polyline and, depending on the event, recreate the block while maintaining its initial creation characteristics.
Unfortunately, after many attempts, I couldn't store the block information within the polyline. In the commented sections of the code, I can create a dictionary and assign it to the polyline, but after the modification (stretch), the dictionary disappears, and I can't access it to obtain the ObjectId of the block and then perform the deletion.
Since I don't have previous experience with the API, I imagine my code is not very good, and I'm also not following any best practices in AutoCAD .NET development, which results in duplicated code and other oddities. In the future, I will strive to produce something better, but for now, I'm just trying to learn and make it work.
I would greatly appreciate it if you could assist me with object linking and perhaps provide tips on best practices in AutoCAD .NET development.
I'm using autoCAD 2020 and visual studio 2019.
I've been looking at some code on the through-the-interface page. This would be the best scenario, where the links are maintained and loaded when loading the drawing, but I think I'm not ready to implement something of such complexity yet.
https://through-the-interface.typepad.com/through_the_interface/2006/11/linking_circles_1.html
I haven't worked with the collisions and other things that must be done yet, so the code produces bad results on very steep curves. I intend to put the minimum bend radius based on the diameter and material properties.
The project is attached, as well as the dwg file in 2010 format.
Thanks in advance for any help.
Best regards, Luís Augusto.