I’m trying to add a Pick Point feature inside a script that pops-up for the user to pick a point in the model. I’ve tried different ways but each of them have its limitation.
- I’ve tried using this script below that comes from LinkDWG package.
#LinkDWG Core DYF by Koz Jono YEOH #email@example.com #Copyright(C) 1994-2020 KozMos Inc. #Copyright(C) 2011-2020 Neila Heaven Networks #Copyright(C) 2017-2020 Tachyon Intelligent Design Institute import clr clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import * import System clr.AddReference('System.Windows.Forms') from System.Windows.Forms import MessageBox msg="Pick a point" osm=169 doc=System.Runtime.InteropServices.Marshal.GetActiveObject("Autocad.Application").ActiveDocument rrr=None if IN == True and doc: try: mbx="Pick a point in the drawing to create new assembly." MessageBox.Show(mbx, "LinkDWG Message") old=doc.GetVariable("osmode") usr=doc.GetVariable("users5") doc.SetVariable("osmode", int(osm)) doc.Activate() doc.SendCommand("(setq pt(getpoint\042" + msg + "\042)) ") doc.SendCommand("(and pt(setvar\042users5\042(strcat(rtos(car pt))\042#\042(rtos(cadr pt))\042#\042(rtos(caddr pt))))(setq pt nil)) ") rtn=doc.GetVariable("users5") doc.SetVariable("osmode", old) if rtn != usr: rtn=rtn.split("#") if len(rtn) == 3: rrr=Point.ByCoordinates(float(rtn),float(rtn),float(rtn)) doc.SetVariable("users5", usr) except: pass else: rrr= OUT = rrr
But having a problem when I have multiple documents opened because the script goes and activates the first opened document session (ei. If two Civil3D sessions are opened - the pick point function is activated in another session that I don’t want). And I found out that this happens since the script goes through the system and GetActiveObejct, it selects the one that was opened first. I think the ‘UIApplication.ActiveUIDocument.Document’ solves this issue for Revit, but haven’t figured out how to apply this to Civil3D.
- Data-Shape pick point node only offer picking point on a face so this is not what I need.
- And there’s a Pick Point node in Civil3D but it doesn’t offer pop-up function and doesn’t work in Dynamo Player either. I have left an inquiry about this already - waiting to hear back.
I think revising LinkDWG script to pick the active document I’m working on would be the best bet, but not sure how to. Can anyone help?