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

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

3 REPLIES 3
Reply
Message 1 of 4
jithin.dcs
600 Views, 3 Replies

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

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
3 REPLIES 3
Message 2 of 4
arcticad
in reply to: jithin.dcs

This was mentioned here
http://discussion.autodesk.com/forums/thread.jspa?messageID=6303436⻌
---------------------------



(defun botsbuildbots() (botsbuildbots))
Message 3 of 4
jithin.dcs
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.
Message 4 of 4
vinodhkumar
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

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