How to implement Explode Command in Python

How to implement Explode Command in Python

Anonymous
Not applicable
1,008 Views
2 Replies
Message 1 of 3

How to implement Explode Command in Python

Anonymous
Not applicable

Does anyone know how to program in python the explode command to be applied to a dynamic block and then get its attributes?

0 Likes
1,009 Views
2 Replies
Replies (2)
Message 2 of 3

fkp7057
Advocate
Advocate

why you need python for this simple AutoCAD thing.

you can use lee mac Burts upgraded Command.

Check the Below link :

http://www.lee-mac.com/upgradedburst.html

Hope this will help you.

0 Likes
Message 3 of 3

hosneyalaa
Advisor
Advisor

HI

BY dynamo Python Script

 

https://forum.dynamobim.com/t/access-attributes-in-blocks/38147/3?u=hosneyalaa

"""
Copyright 2019 Autodesk, Inc. All rights reserved.

This file is part of the Civil 3D Python Module.

"""
__author__ = 'Paolo Emilio Serra - paolo.serra@autodesk.com'
__copyright__ = '2019'
__version__ = '1.0.0'

import clr

# Add Assemblies for AutoCAD and Civil 3D APIs
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('acdbmgdbrep')
clr.AddReference('System.Windows.Forms')
clr.AddReference('AutoCADNodes')

# Add standard Python references
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
import os
import math

# Add references to manage arrays, collections and interact with the user
from System import *
from System.IO import *
from System.Collections.Specialized import *
from System.Windows.Forms import MessageBox

# Create an alias to the Autodesk.AutoCAD.ApplicationServices.Application class
import Autodesk.AutoCAD.ApplicationServices.Application as acapp

# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

# Import references for PropertySets
from Autodesk.Aec.PropertyData import *
from Autodesk.Aec.PropertyData.DatabaseServices import *

# Import references for Civil 3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

# Import Dynamo for AutoCAD nodes
from Autodesk.AutoCAD.DynamoNodes import *

adoc = acapp.DocumentManager.MdiActiveDocument
ed = adoc.Editor

# Example function
def get_block_references_tag(input):
	"""
	Description....
	:param first_param: ....
	:returns: ....
	"""
	if not isinstance(input, BlockReference):
		return
	
	input = input.InternalDBObject
	
	if len(input.AttributeCollection) == 0:
		return []
		
	global adoc
	
	output = {}

	with adoc.LockDocument():
		with adoc.Database as db:
			with db.TransactionManager.StartTransaction() as t:
				bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
				btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
				
				for oid in input.AttributeCollection:
					att = t.GetObject(oid, OpenMode.ForWrite)
					output[att.Tag] = att.TextString

				t.Commit()
	return output
	
	
OUT = get_block_references_tag(IN[0])

 

Capture.JPG

 

0 Likes