.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

transforming DWG Entities to Blocks

4 REPLIES 4
Reply
Message 1 of 5
Nawara17
342 Views, 4 Replies

transforming DWG Entities to Blocks

Hi everyone,
Please, can somebody help? i am a programmer, and i am novice in autocad drawings. I had attached a drawing, that i don't know how it was created. it seems that the entities were grouped. but they are not blocks. am I right????

i want to read each group of entities and add a block definition for it if i didn't read similar group before and the group of entities that i read should be a block reference. can i do that using C#?? and are these groups of entities or blocks??
or everything that i said is wrong??

Thanks in advance 🙂
4 REPLIES 4
Message 2 of 5
Nawara17
in reply to: Nawara17

Sorry this is the attachment.
Message 3 of 5
mjwalsh51
in reply to: Nawara17

Nawara17,

The entities are not grouped or made into blocks. Go to help & you will see that creating blocks are pretty straightforward.
You can tell what an entity is selected by clicking on it & it is hilighted. if the properties window is open you will see what type of entity or entities are there. If you are really good with C# it would be nice if you would share some of your successes.

The advantage to blocks usually is attaching associated data & subnesting other blocks etc. Also the ability to reuse the already defined group of entities called a block.

I do not know of a situation where it makes sense to initially create block with any type of programming.

I personally think that connecting just the entity's xdata directly to a relational database makes more sense than blocks but requires some programming ability.
Message 4 of 5
Nawara17
in reply to: Nawara17

thanks Mike, I found that there are entities when I created this peace of code.

using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Collections;
using AcadAPP=Autodesk.AutoCAD.ApplicationServices.Application;

namespace ClassLibrary4
{
///
/// Summary description for Class1.
///

public class Class1:Autodesk.AutoCAD.Runtime.IExtensionApplication
{
public void Initialize()
{
Autodesk.AutoCAD.Interop.AcadApplication AcadApp=(Autodesk.AutoCAD.Interop.AcadApplication)Marshal.GetActiveObject("AutoCAD.Application.16.2");
Autodesk.AutoCAD.Interop.AcadDocument AcadDoc=AcadApp.ActiveDocument;
Database db = HostApplicationServices.WorkingDatabase;
Transaction trans = db.TransactionManager.StartTransaction();
try
{
BlockTable bt = (BlockTable)trans.GetObject(HostApplicationServices.WorkingDatabase.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);
//MessageBox.Show();
foreach (ObjectId id in btr)
{
MessageBox.Show("HI");
Entity ent = (Entity)trans.GetObject(id, OpenMode.ForWrite, false);
////////////////////////////////The following code i copied it from RonaldF Message in
////////////// http://discussion.autodesk.com/thread.jspa?messageID=5205357
ObjectId[] ids = new ObjectId[1];

ids[0] = ent.Id;

SubentityId index = new SubentityId(SubentityType.Edge, 0);

FullSubentityPath path = new FullSubentityPath(ids, index);

ent.Highlight(path, true);
///////////////////////////////////////////////////////////////////////////////


}
}
finally
{
trans.Dispose();
}
}
public void Terminate()
{
}
}


I found that when each message box appear the whole shelves where highlighted.

if I create the code which i asked to I will post it here in this discussion. Nawara17
Message 5 of 5
Nawara17
in reply to: Nawara17

ent.equals(anotherEnt);
ent.CompareTo(anotherEnt);

these two statments are comparing the objects not the shapes of the entities.

Please, Can anybody tell me, how could i know by comparing two entities that their shapes are similar??

Thanks in advance.

Nawara==>Noora

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost