Delete TinsurfacePoints

Hi.
Is it possible to delete points from a Tinsurface?
I want to delete the red marked points. I know them and i have them in a list.

image


My idea is:
IN[1] → Tinsurface
IN[2] → Points (X,Y) (List)
OUT → Tinsurface

I haven’t learned python yet and I don’t have much experience with API’s.
Maybe there is someone out there who knows this :slight_smile:

Hi
May this help you


1 Like

I’ll try my hand at the python when I find some time.

Found a bit of time. Here is the python solution:
Delete Tin Surface Points.dwg (692.8 KB)


DeleteTinSurfacePoints.dyn (16.6 KB)

# Load the Python Standard and DesignScript Libraries
import sys
import clr

# 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 *

# The inputs to this node will be stored as a list in the IN variables.
surfaceName = IN[0]
inputPoints = IN[1]

deletePoints = [Point3d(inputPoint.X, inputPoint.Y, inputPoint.Z) for inputPoint in inputPoints]

adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor

with adoc.LockDocument():
    with adoc.Database as db:

        with db.TransactionManager.StartTransaction() as t:
            bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
            btrID = bt.get_Item("*Model_Space")
            btr = t.GetObject(btrID, OpenMode.ForWrite)
            
            

            for oid in btr:
                obj = t.GetObject(oid, OpenMode.ForWrite)
                
                if isinstance(obj, TinSurface) and obj.Name == surfaceName:
                    tinSurface = obj
            
            
            vertices = tinSurface.Vertices

            verticesToDelete = []
            for vertex in vertices:
                if vertex.Location in deletePoints:
                    verticesToDelete.append(vertex)
                    
            tinSurface.DeleteVertices(verticesToDelete)
            
                
            
            t.Commit()
            pass

# Assign your output to the OUT variable.
OUT = "Done"

3 Likes

Hi Shaun.
Thank you for your quick response.
In your file it worked perfectly

I have tried your node in my file but i get a failure.
Maybe you can check where the problem is?

Idea:
Maybe it can skip the points which can’t get deleted and we get an OUT[2] with a Working/Failure message?

I want to delete these points, so i don’t have this “walls” in my surface.


The “Planum” is created by a list of (smaller) surfaces.
The gap between the surfaces is needed beaucse of the offset from the smaller surfaces to eathother.
I get the “walls” when i give the “Planum”-surface a boundary line so the gaps will be closed.

TEST_Delete-Tin-Surface-Points.dwg (6.7 MB)
TEST_GB_C3D_Surface-Delete-Points.dyn (164.9 KB)
_GB_VF-Aufbauten-Stile.xlsx (21.5 KB)

Notice:
My script is only a part of a much bigger one.
You also need an Excel-file, because the script compares used and usable featurelinestyles.

1 Like

You have a lot going on in your script and it’s difficult without any background to understand exactly what you’re trying to do. I’m getting a load of errors when trying to run the script. Are you getting any other errors?
I believe the error you are getting means you are passing an empty list of vertices into the point delete method. I can’t seem to get a successful run of the script up to the python node so I’ll need to see what you’re feeding into the node. What is the data preview output of your “List.Flatten” node that you’re feeding into the python script?

Set your OUT to:

OUT = verticesToDelete

Do you get an empty list?

Hi.
I have no problems. i have used the same files i posted here.

And there is no empty list in the list of points.

Normaly, after you set the Excelfile, the script should work.
image

And here are the used packages:
image

Hi I didn’t try it
I think the problem is the points in excel do not match the points on the existing surface vary in accuracy
So make a list of surface points with the list of excel points to select it with a filter

The excel file has no pointinformation in it.
It contains featureline-stylenames and is necessary to filter the usable featurelines in the drawing.
image
(in the meantime i have optimized the file :smiley: )

The Points are created then from these featurelines (yellow lines).