diff --git a/Images/CadPythonShell.png b/Images/CadPythonShell.png
new file mode 100644
index 0000000..e695c6e
Binary files /dev/null and b/Images/CadPythonShell.png differ
diff --git a/README.md b/README.md
index d19dfb1..e9885b1 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,19 @@
+
+
+## 💖 Support This Project
+
+If you like this project and want to support its development, please consider making a donation. Your contributions will help us continue to improve and maintain the project.
+
+
+
+
+
+
+
+
## Introduction
This is obviously a fork of [RevitPythonShell](https://github.com/architecture-building-systems/revitpythonshell), bringing an IronPython interpreter to Autodesk Autocad,
@@ -157,7 +170,7 @@ Thanks for providing a free All product IDE for this project.
## Credits
* Daren Thomas (original RPS Developer) [RPS](https://github.com/architecture-building-systems/revitpythonshell)
- * Joe Moorhouse (interactive shell was taken from his project [IronLab](http://ironlab.net/))
+ * Joe Moorhouse (interactive shell was taken from his project [IronLab](https://code.google.com/archive/p/ironlab/)
* [Dimitar Venkov](https://github.com/dimven/NavisPythonShell) (original port to Navisworks)
* [ChuongMep](https://github.com/chuongmep) (original port to Autocad)
* The rest of the RPS contributors
diff --git a/Script Examples/ironpython3.4/collectPolylinesAndWriteTextInCenter.py b/Script Examples/ironpython3.4/collectPolylinesAndWriteTextInCenter.py
new file mode 100644
index 0000000..622edc3
--- /dev/null
+++ b/Script Examples/ironpython3.4/collectPolylinesAndWriteTextInCenter.py
@@ -0,0 +1,86 @@
+# Many thanks to Chuong Ho for this awesome repository
+# Many thanks Cyril-Pop for the starting point in this script.
+
+import clr
+clr.AddReference('acmgd')
+clr.AddReference('acdbmgd')
+clr.AddReference('accoremgd')
+
+# 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 *
+
+# Global AutoCAD variables
+doc = Application.DocumentManager.MdiActiveDocument
+ed = doc.Editor
+db = doc.Database
+
+# Layer names
+polyline_layer_name = "Aux-REVISION"
+text_layer_name = "I-WALL"
+
+def polyline_center(polyline):
+ """
+ Calculates the approximate geometric center of a polyline.
+ """
+ extents = polyline.GeometricExtents
+ center = Point3d(
+ (extents.MinPoint.X + extents.MaxPoint.X) / 2,
+ (extents.MinPoint.Y + extents.MaxPoint.Y) / 2,
+ (extents.MinPoint.Z + extents.MaxPoint.Z) / 2
+ )
+ return center
+
+def create_text(btr, trans, position, text_value, text_layer):
+ """
+ Creates a text entity in AutoCAD and adds it to the model space.
+ """
+ text = DBText()
+ text.Position = position
+ text.Height = 3 # Text height
+ text.TextString = text_value # Text content
+ text.Layer = text_layer # Assign the text to the specified layer
+ btr.AppendEntity(text)
+ trans.AddNewlyCreatedDBObject(text, True)
+ return text
+
+def main():
+ output = [] # List to store created texts
+ errors = [] # List to record errors
+
+ with doc.LockDocument(): # Lock the document
+ with db.TransactionManager.StartTransaction() as t:
+ # Access the model space
+ bt = t.GetObject(db.BlockTableId, OpenMode.ForRead)
+ btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
+
+ # Iterate through the entities in model space
+ for objectid in btr:
+ blkRef = t.GetObject(objectid, OpenMode.ForRead)
+ if isinstance(blkRef, Polyline) and blkRef.Layer == polyline_layer_name:
+ try:
+ # Get the geometric center of the polyline
+ center = polyline_center(blkRef)
+
+ # Create a unique text entity at the center of the polyline
+ text = create_text(btr, t, center, f"Text-{len(output) + 1}", text_layer_name)
+ output.append(text)
+ except Exception as e:
+ errors.append((blkRef, str(e)))
+ ed.WriteMessage(f"\nError processing polyline: {e}")
+ else:
+ errors.append(blkRef)
+
+ # Commit the transaction
+ t.Commit()
+
+ # Results
+ ed.WriteMessage(f"\n{len(output)} texts were created.")
+ if errors:
+ ed.WriteMessage(f"\nErrors found: {len(errors)}")
+
+if __name__ == "__main__":
+ main()
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy