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]

1 Like

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

Hi,

I got it also to work with only this code:

import Autodesk.DesignScript.Geometry as DS

def ConvertToDSPoint(cadPt):
	pt = DS.Point.ByCoordinates(cadPt.X, cadPt.Y, cadPt.Z)
	return pt
	
OUT = [ConvertToDSPoint(x) for x in IN[0]]

Looks like you have a solution, but FYI there’s also a node in Camber to get the location/insertion point of a profile view.

3 Likes

Cool. Any ideas why it isn’t workiong for me? In Python it says Point has no ByCoordinates attribute.
If done in CodeBlock it returns Null. Civil3D 2022.1

What happens when you copy the code 1 to 1 into an empty Python node?

Could you place a list.create node between the ObjectExtensions node and the Python node?


It is strange, it’s like it isn’t loaded, but in the editor the autocomplete is working.

I have no idea why it is working for me, but not for you. Maybe you could create a new topic referring to this one.

I guess it is on my end, I’ll try closing and reopening later. Thanks anyway.

1 Like

If the hierarchy of the listings goes up to @L2 as in the image, how should Python be rewritten?
image

@hosneyalaa
Thanks!