{ "Uuid": "a41888ff-67e6-43a2-9b67-d71f57f28fd9", "IsCustomNode": false, "Description": "", "Name": "Annotation2", "ElementResolver": { "ResolutionMap": {} }, "Inputs": [], "Outputs": [], "Nodes": [ { "ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels", "NodeType": "PythonScriptNode", "Code": "# Load the Python Standard and DesignScript Libraries\r\nimport sys\r\nimport clr\r\n\r\n# Add Assemblies for AutoCAD and Civil3D\r\nclr.AddReference('AcMgd')\r\nclr.AddReference('AcCoreMgd')\r\nclr.AddReference('AcDbMgd')\r\nclr.AddReference('AecBaseMgd')\r\nclr.AddReference('AecPropDataMgd')\r\nclr.AddReference('AeccDbMgd')\r\n\r\n# Import references from AutoCAD\r\nfrom Autodesk.AutoCAD.Runtime import *\r\nfrom Autodesk.AutoCAD.ApplicationServices import *\r\nfrom Autodesk.AutoCAD.EditorInput import *\r\nfrom Autodesk.AutoCAD.DatabaseServices import *\r\nfrom Autodesk.AutoCAD.Geometry import *\r\n\r\n# Import references from Civil3D\r\nfrom Autodesk.Civil.ApplicationServices import *\r\nfrom Autodesk.Civil.DatabaseServices import *\r\n\r\nSTART_OFFSET = 0.03\r\nSLOPE_D = 1\r\nDASH = 0.1\r\nR = 0.13\r\nTEXT_HEIGHT = 0.12\r\nTEXT_OFFSET = 0.1\r\n\r\n# The inputs to this node will be stored as a list in the IN variables.\r\ndataEnteringNode = IN\r\n\r\nadoc = Application.DocumentManager.MdiActiveDocument\r\neditor = adoc.Editor\r\n\r\nwith adoc.LockDocument():\r\n with adoc.Database as db:\r\n\r\n with db.TransactionManager.StartTransaction() as t:\r\n space = t.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)\r\n if space.Name == '*Model_Space':\r\n ModelSpace = space\r\n cracks = []\r\n for id in ModelSpace:\r\n obj = t.GetObject(id, OpenMode.ForRead)\r\n if isinstance(obj, Polyline3d):\r\n cracks.append(obj)\r\n for pl3d_crack in cracks:\r\n ext_dicID = pl3d_crack.ExtensionDictionary\r\n ext_dic = t.GetObject(ext_dicID, OpenMode.ForRead)\r\n ps_dicID = ext_dic['AEC_PROPERTY_SETS']\r\n ps_dic = t.GetObject(ps_dicID, OpenMode.ForRead)\r\n psID = ps_dic['*A1']\r\n PropertySet = t.GetObject(psID, OpenMode.ForRead)\r\n l = PropertySet.GetAt(1)\r\n no = PropertySet.GetAt(2)\r\n k = 0\r\n for VertexID in pl3d_crack:\r\n if k==1:\r\n break\r\n k += 1\r\n vertex = t.GetObject(VertexID, OpenMode.ForRead)\r\n \r\n # line\r\n pts = Point3dCollection()\r\n x = vertex.Position.X + START_OFFSET\r\n y = vertex.Position.Y + START_OFFSET\r\n z = vertex.Position.Z\r\n pts.Add(Point3d(x, y, z))\r\n x += SLOPE_D\r\n y += SLOPE_D\r\n pts.Add(Point3d(x, y, z))\r\n x += DASH\r\n pts.Add(Point3d(x, y, z))\r\n pl3d_annot = Polyline3d(Poly3dType.SimplePoly, pts, False)\r\n ModelSpace.AppendEntity(pl3d_annot)\r\n t.AddNewlyCreatedDBObject(pl3d_annot, True)\r\n \r\n # circle\r\n x += R\r\n center = Point3d(x, y, z)\r\n normal = Vector3d(0, 0, 1)\r\n circle = Circle(center, normal, R)\r\n ModelSpace.AppendEntity(circle)\r\n t.AddNewlyCreatedDBObject(circle, True)\r\n \r\n # text\r\n y -= 0.5*TEXT_HEIGHT\r\n # number\r\n txt_n = DBText()\r\n txt_n.Height = TEXT_HEIGHT\r\n txt_n.Position = center\r\n txt_n.TextString = str(no)\r\n extents = txt_n.GeometricExtents\r\n wt = extents.MaxPoint.X - extents.MinPoint.X\r\n txt_n.Position = Point3d(x-0.5*wt, y, z)\r\n ModelSpace.AppendEntity(txt_n)\r\n t.AddNewlyCreatedDBObject(txt_n, True)\r\n # length\r\n x += (R+TEXT_OFFSET)\r\n txt_l = DBText()\r\n txt_l.Height = TEXT_HEIGHT\r\n txt_l.TextString = f'{round(l, 2)}, {round(pl3d_crack.Length, 2)}'\r\n txt_l.Position = Point3d(x, y, z)\r\n ModelSpace.AppendEntity(txt_l)\r\n t.AddNewlyCreatedDBObject(txt_l, True)\r\n\r\n else:\r\n Application.ShowAlertDialog(f'Current Space: {space.Name}')\r\n\r\n t.Commit()\r\n\r\n# Assign your output to the OUT variable.\r\nOUT = 0\r\n", "Engine": "CPython3", "VariableInputPorts": true, "Id": "ad96c96320bf4b21aaf14b73aed76c26", "Inputs": [ { "Id": "c7ffa9a6edd74ca1a7d8c1cf50446fd4", "Name": "IN[0]", "Description": "Input #0", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false } ], "Outputs": [ { "Id": "fcb0793707d3441397fdeb9e7e699e6c", "Name": "OUT", "Description": "Python スクリプトの結果", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false } ], "Replication": "Disabled", "Description": "埋め込み Python スクリプトを実行します。" } ], "Connectors": [], "Dependencies": [], "NodeLibraryDependencies": [], "Thumbnail": "", "GraphDocumentationURL": null, "ExtensionWorkspaceData": [ { "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", "Name": "Properties", "Version": "2.12", "Data": {} } ], "Author": "", "Linting": { "activeLinter": "なし", "activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a", "warningCount": 0, "errorCount": 0 }, "Bindings": [], "View": { "Dynamo": { "ScaleFactor": 1.0, "HasRunWithoutCrash": true, "IsVisibleInDynamoLibrary": true, "Version": "2.12.0.5650", "RunType": "Manual", "RunPeriod": "1000" }, "Camera": { "Name": "背景プレビュー", "EyeX": -17.0, "EyeY": 24.0, "EyeZ": 50.0, "LookX": 12.0, "LookY": -13.0, "LookZ": -58.0, "UpX": 0.0, "UpY": 1.0, "UpZ": 0.0 }, "NodeViews": [ { "ShowGeometry": true, "Name": "Python Script", "Id": "ad96c96320bf4b21aaf14b73aed76c26", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "X": 594.60470377711954, "Y": 271.19764811144023 } ], "Annotations": [], "X": -171.51648016400475, "Y": -21.071093258121095, "Zoom": 0.91006380393143915 } }