Autodesk.Autocad.Geometry.Point3d to DS geometry

Hey Guys,

I try to get the insertion point of a profile view but, I have the following issue:

I am unable to convert the Point3d object to Dynamo point. I could make it work with workarounds like creating string from the values and slice it, but I’m looking for a more convinient way. Any ideas?

Thanks in advance.

code in the script found on the Forum:

import sys
import clr
clr.AddReference('ProtoGeometry')
import Autodesk
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')

# 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 from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *


def ConvertToDSPoint(cadPt):
	pt = DS.Point.ByCoordinates(cadPt.X, cadPt.Y, cadPt.Z)
	return pt
# The inputs to this node will be stored as a list in the IN variables
lstCadPoint = IN[0]

OUT = [ConvertToDSPoint(x) for x in IN[0]]

Please attached dynamo file

if not isinstance(IN[0], list):
   profileViews = [IN[0]]

OUT = [ConvertToDSPoint(x) for x in profileViews]

GetPVIsertionPt.dyn (14.5 KB)
GetPVisertionPt.dwg (2.4 MB)

import sys
import clr
clr.AddReference('ProtoGeometry')
import Autodesk
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')

# 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 from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *


def ConvertToDSPoint(cadPt):
	pt = DS.Point.ByCoordinates(cadPt.X, cadPt.Y, cadPt.Z)
	return pt
# The inputs to this node will be stored as a list in the IN variables
#lstCadPoint = IN[0]
if not isinstance(IN[0], list):
   profileViews = [IN[0]]

OUT = [ConvertToDSPoint(x) for x in profileViews]

#OUT = [ConvertToDSPoint(x) for x in IN[0]]
1 Like

Thanks. Could you give me a brief explanation for learning purposes?

I don’t have enough experience
I asked for the code to try it
I tried on one item and it worked
I understand I should IN[0] list
So add a condition
if not isinstance(IN[0], list): profileViews = [IN[0]]

1 Like