![]() ![]() When included in a Block definition, such entities use the Block color. Match to Block: New entities appear in black or white (depending on the screen background color). In other words, this method is fusing entities together so that picking one of them selects all of them and they all share the same xrecord. Match to Layer: New entities use the color assigned to the Layer on which you create them. If I call the method it creates a blocktablerecord that contains all entities I select but I need the selected entities to become a block. Thanks for your reply Jeff! You're right in that it runs without error but it doesn't accomplish what I want it to. _database.DeepCloneObjects(collection, blockId, mapping, false) ObjectIdCollection collection = new ObjectIdCollection(entitiesToJoin) ![]() copy the select entities to block by using deepclone. Record.AppendEntity(entityToAdd) /*This line throws an eAlreadyInDb error*/ It looks like it should work but it throws an eAlreadyInDatabase error when I try to append each entity to the blocktablerecordīlockTable bt = (BlockTable)tr.GetObject(_database.BlockTableId, OpenMode.ForRead) //Getting block table to put new record inīlockTableRecord record = new BlockTableRecord() //New record will contain all entities which will make up the blockįoreach (ObjectId id in entitiesToJoin) //Appending each entity to the blocktablerecord This method is based directly off the links you posted. Using (DocumentLock docLock = _activeDocument.LockDocument())Įntity baseEntity = tr.GetObject(entitiesToJoin, OpenMode.ForWrite) as Entity //The first entity will be the basis for joining all the other entities togetherįoreach (ObjectId id in entitiesToJoin) //Creating the block referenceĮntity entityToAdd = tr.GetObject(id, OpenMode.ForWrite) as Entity īut the JoinEntity method call throws an eInvalidInput exception even though I'm passing in an entity as the second argument. ObjectId entitiesToJoin = PromptUserForEntities() //Getting the ids of all the entities to append to the new block table record I've written a method which does that.īlockTableRecord newBlockTableRecord = new BlockTableRecord() //Record which will hold all the entities we want to fuse into a block I'm thinking I can just use the first selected entity as a base and join all the other selected entities to it to accomplish what I want. I started implementing a solution that was based off of the links you gave me when I came upon a method in the entities class called JoinEntity. ![]() My problem is that I have no idea how or if it is possible to take a list of entities and join them into a blockreference. / /// Returns all entities in an AutoCAD drawing in a list /// public static List GetEntitiesInDrawing () I'm trying to write a method that prompts the user to select all the entities they want to combine into a block and then joins them together into a block and returns the block reference. ![]()
0 Comments
Leave a Reply. |