p7q Posted 7 hours ago Posted 7 hours ago I am working on an AutoLISP routine where I need to explode a block/table object during the execution of my custom command. Currently I am using: (command "._EXPLODE" obj "") The object is exploded, and my routine usually continues, but AutoCAD also prints an “Unknown command” message after the EXPLODE operation. When I remove this EXPLODE line, the problem disappears. From what I understand, the issue may be related to using the AutoCAD EXPLODE command inside another running AutoLISP command. After the explode operation, AutoCAD may refresh or lose the expected command context, so the remaining input is interpreted incorrectly. I need to explode the object because I have to access/fill attribute-related data from the resulting entities. However, I must preserve the original block/table placement exactly: insertion point, rotation, scale, and geometry position should remain unchanged. It would also be acceptable if only the entities on a specific layer are exploded or copied out. Is there a safer/custom AutoLISP or Visual LISP way to explode a block/table object without using (command "._EXPLODE" ...)? For example, is using vla-Explode recommended in this case? If so, how can I explode or copy the block contents while preserving their transformed position, rotation, and scale exactly as they appear in the drawing? Any example function or best-practice approach would be helpful. Quote
p7q Posted 3 hours ago Author Posted 3 hours ago 2 hours ago, GLAVCVS said: Have you tried vla-explode? Yes, its work but I dont want to vla functions because this functions dont work acad LT. So I looking for alternative Quote
GLAVCVS Posted 1 hour ago Posted 1 hour ago Perhaps you just need to simplify it like this: (command ".-explode" obj) Quote
SLW210 Posted 1 hour ago Posted 1 hour ago You could make an AutoCAD LT code and a an AutoCAD code. Quote
Danielm103 Posted 59 minutes ago Posted 59 minutes ago This is what I use; I sent a support request to Bricsys, I ported it to C++ for the report since they don’t directly support Python (only BRX) from pyrx import Ap, Db, Ed, Ge #SR 223468 BRX def check_layout_status(source_db: Db.Database, dest_db: Db.Database, layout_name: str) -> bool: source_layout_dict = Db.Dictionary(source_db.layoutDictionaryId()) if not source_layout_dict.has(layout_name): print(f"Layout '{layout_name}' not found in source drawing.") return False dest_layout_dict = Db.Dictionary(dest_db.layoutDictionaryId()) if dest_layout_dict.has(layout_name): print(f"Layout '{layout_name}' already exists") return False return True def clone_layout_from_db(source_db: Db.Database, dest_db: Db.Database, layout_name: str): if not check_layout_status(source_db, dest_db, layout_name): return source_layout_dict = Db.Dictionary(source_db.layoutDictionaryId()) source_layout_id = source_layout_dict.getAt(layout_name) id_map = Db.IdMapping() id_map.setDestDb(dest_db) source_db.wblockCloneObjects( [source_layout_id], dest_db.layoutDictionaryId(), id_map, Db.DuplicateRecordCloning.kDrcIgnore, ) @Ap.Command() def doit(): layoutName = "S7" source_path = "E:\\Batch\\06457 RE Submittal.dwg" dest_db = Db.curDb() source_db = Db.Database.createFromDWG(source_path) clone_layout_from_db(source_db, dest_db, layoutName) Ap.Application.refreshMainWindow() Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.