.NET

Reply
Active Contributor
jithin.dcs
Posts: 31
Registered: ‎09-11-2009
Message 1 of 4 (313 Views)

change block refference attribute. Dont want to change the block itself.

313 Views, 3 Replies
03-07-2010 09:21 PM
I have an issue regarding nesed entity.

Thanks in advace.
Herewith I explained the issue that I am facing now. Please reply as fast as possible.

I have a nested entity block reference. In this entity I have three blocks. if I change any of the block reference attribute defenision in the nested block reference then it is changing the original block itself.
Actually I am getting the handle of the selected block reference in the nested Entity. and change the attribute refference later. but it is making change in the block itself and other block reference too.

Here is my code:
static public void CONTACTS()
{

Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
string contactName = string.Empty;//to hold contact name, from xdata
System.Collections.ArrayList arrXdata = new ArrayList();//array list to save array list
PromptNestedEntityResult rs = ed.GetNestedEntity("\nSelect the contact to move:");
string contactPath = GetSymbolPath();//get the symbol path
contactPath += "Contacts//IS";//set contact path
Handle parentContactID =new Handle();
string parentContactLayerName = string.Empty;//get the parent contact layer name
string parentContactPosition = string.Empty;//get the parent contact position
string parentDesignation = string.Empty;//get the parent designation
string currentLayerName =string.Empty;
System.Collections.Generic.Dictionary dictAttributes = new System.Collections.Generic.Dictionary();
if (rs.Status == PromptStatus.OK)
{
ObjectId[] objIds = rs.GetContainers();
//Get the selected nested entity layer name and designation of the nested entity//////////////////////////////////////////////
foreach (ObjectId dd in objIds)
{
Transaction tr = doc.TransactionManager.StartTransaction();
using (tr)
{
AttributeReference attRefParent=null;
Entity en = (Entity)tr.GetObject(dd, OpenMode.ForRead);
if (en is BlockReference)
{
BlockReference rf = en as BlockReference;
Handle hn=rf.Handle; ///////////////????????? I am getting the handle here

}
}
}

}
}
}

Edited by: jithin.dcs on Mar 8, 2010 10:53 AM Edited by: jithin.dcs on Mar 8, 2010 10:54 AM
*Expert Elite*
arcticad
Posts: 1,285
Registered: ‎06-21-2004
Message 2 of 4 (313 Views)

Re: change block refference attribute. Dont want to change the block itself.

03-07-2010 10:38 PM in reply to: jithin.dcs
This was mentioned here
http://discussion.autodesk.com/forums/thread.jspa?messageID=6303436⻌
---------------------------



(defun botsbuildbots() (botsbuildbots))
Active Contributor
jithin.dcs
Posts: 31
Registered: ‎09-11-2009
Message 3 of 4 (313 Views)

Re: change block refference attribute. Dont want to change the block itself.

03-08-2010 12:22 AM in reply to: jithin.dcs
I checked the link you have given. its not clear my issue.

Im my code I am reading the selected block reference handle as follows.

ObjectId id = (ObjectId)revIds.GetValue(1);// from nested entity collections
Entity ent = (Entity)tr.GetObject(id, OpenMode.ForRead);
// ... and highlight the nested entity
ent.Highlight(path,true);
if (ent is BlockReference)
{
BlockReference br = ent as BlockReference;
contactName = br.Name;
parentContactID = br.Handle; // getting the handle here
}

Once I got the handle I will update the sabe block reference as follows

ObjectId getParentID = db.GetObjectId(false,handle, 0);
Entity entParent = (Entity)tr.GetObject(getParentID, OpenMode.ForWrite, false);// Use it to open the current object!
if (entParent is BlockReference)
{
BlockReference brParent = entParent as BlockReference;
foreach (ObjectId id in brParent.AttributeCollection)
{
Entity ent2 = (Entity)tr.GetObject(id, OpenMode.ForRead, false);
attRef = (AttributeReference)tr.GetObject(id, OpenMode.ForWrite, false);
if (attRef.Tag == "LOCN")
{
attRef.TextString = "[" + subContactLayer + ":" + subContactPosition + "]";
}
}
}

But it is updating the original bokc attribute also...........................
please replay.
Member
vinodhkumar
Posts: 5
Registered: ‎06-04-2012
Message 4 of 4 (128 Views)

Re: getting entity by giving the handle name in autocad,net

06-07-2012 04:52 AM in reply to: jithin.dcs

my requirement is i am giving the handle name in the textbox.

    with that handle name i want to zoom tha that object when i pree button

 

please give logic

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community