AutoCAD Project

AutoCAD Project

imrantheman12
Participant Participant
604 Views
5 Replies
Message 1 of 6

AutoCAD Project

imrantheman12
Participant
Participant

Hello, can someone help me figure out something for a project I have with AutoCAD. 

I have a drawings ready in a .dwg file. These drawings are going to be blocks with attributes. I need to write a code using .NET and C# on Microsoft Visual Studio. I need this code to choose from one of the blocks and drop it into a new file. 

 

Then I need to be able to write a code that can go through each line of the drawings and fill in the attributes from data in an excel sheet.

 

This is an image of the blocks.

 

Thank you.

 

2022_07_12_15_32_49_Greenshot.png

0 Likes
605 Views
5 Replies
Replies (5)
Message 2 of 6

AVCPlugins
Advisor
Advisor

To copy a block to a file, one line of code is enough:

sourceDb.WblockCloneObjects(col, newdb.BlockTableId, map, DuplicateRecordCloning.Replace, false);
(However, this code does not insert the block reference into model space. This is a bit more complicated.)


To fill in the attributes according to the table, you need to clearly formulate the matching rules - what data to insert into which block. The process of writing attributes is also not a problem.

 

The question is, do you want to learn how to program or are you looking for a developer?


Plugins for AutoCAD
A>V>C>
AppStore | Facebook | Twitter | YouTube | Blog
Message 3 of 6

imrantheman12
Participant
Participant

I definitely want to learn how to program, but I am not sure about what I am doing or where to start. This is my first time doing a project like this and I not too familiar with coding, especially not with creating code for AutoCAD. Would you be able to guide me? Thank you!

0 Likes
Message 4 of 6

AVCPlugins
Advisor
Advisor

To get started, you must have programming experience. At least in some language. Preferably object oriented programming (OOP). You need to start with the basics and not with the AutoCAD API.
Further, I would recommend that you take ready-made examples (there are actually millions of them) and implement them as is. And then try to change to suit your needs.
Only then should you start your own projects.


Plugins for AutoCAD
A>V>C>
AppStore | Facebook | Twitter | YouTube | Blog
0 Likes
Message 5 of 6

imrantheman12
Participant
Participant

I am currently learning C#, and was assigned this project to get done. I am learning as I go. I have been trying to find example projects to reference from, and was wondering where else I could find example projects besides the link you provided?

0 Likes
Message 6 of 6

AVCPlugins
Advisor
Advisor

Personally, I learned from the examples on Kean Walmsley's blog. That was enough for me. There are other blogs as well. In addition, the documentation for the .Net API and the ObjectARX package (which you will need anyway) have many examples in C#. But try to google any method from the AutoCAD.Net API and you will find a lot of examples.


Plugins for AutoCAD
A>V>C>
AppStore | Facebook | Twitter | YouTube | Blog
0 Likes