.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Autocad Civil3D CogoPointCollection.ImportPoints() Method - No Points transferred

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
joshmcdalton
953 Views, 9 Replies

Autocad Civil3D CogoPointCollection.ImportPoints() Method - No Points transferred

I have been writing a program that imports points from a selected file. I know about importing points from insert tab on the ribbon, but I want this to run after some other code that I have. Every time I run this code, I get the error that no points were transferred from file. I have attached the file I am pulling for reference. I am at a complete loss and have been working on this for a few days now. Any help would be appreciated! Thanks!

 

 

 

Imports Autodesk.Civil.ApplicationServices
Imports Autodesk.Civil.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Public Class Class1

    Public Shared Sub importPointsFromFile()
        Dim acDoc As Document = Core.Application.DocumentManager.MdiActiveDocument
        Dim civilDoc As CivilDocument = CivilApplication.ActiveDocument
        Dim acCurDb As Database = acDoc.Database
        Using trans As Transaction = acCurDb.TransactionManager.StartTransaction()
            Dim pointFileName As String = "C:\Users\jdalton\Desktop\091021_PCV3_ASB_SH.csv"
            Dim pointFileFormatName As String = "PNEZD (comma delimited)"
            Dim pointFileFormat As PointFileFormat = PointFileFormatCollection.GetPointFileFormats(acCurDb).Item(pointFileFormatName)
            Dim pointGroupId As ObjectId = civilDoc.PointGroups.Add("-FIELD IMPORT")
            Dim result As UInteger = CogoPointCollection.ImportPoints(pointFileName, pointFileFormat, False, False, False, pointGroupId)
            trans.Commit()
        End Using
    End Sub
End Class

 

 

 

 Also I am using AutoCAD Civil3D 2022 and 4.7.2 Net Framework

 

Edit: I have also tried having a Cogo Point in the blank drawing to see if that would do anything. I also attached the error picture.

 

Edit 2: I get an error also adding the point group on line 15 and another error when adding the points (with and without the inclusion of pointgroupId)

Labels (5)
9 REPLIES 9
Message 2 of 10
hosneyalaa
in reply to: joshmcdalton
Message 3 of 10
joshmcdalton
in reply to: hosneyalaa

Hi @hosneyalaa! Thanks for the response, but this just leads to the spot I am at now. The thread states that it is possible and the give the example from the API which is what I have copied and pasted into my program. Unless it is still not possible...
Message 4 of 10
hosneyalaa
in reply to: joshmcdalton

Hi @joshmcdalton 

 Never tried it before

But try to be a .txt file

 and not .csv file 

 

 

 

Message 5 of 10
joshmcdalton
in reply to: hosneyalaa

Unfortunately, I get the same error
Message 6 of 10
hosneyalaa
in reply to: joshmcdalton

No problem

Tomorrow I will try it out

as an idea

 Can you read the text file?

and create points Then create a group to enter

As in the link in the first reply to thank

Message 7 of 10
joshmcdalton
in reply to: hosneyalaa

I cannot, I still get no points transferred from file.
Thanks
Message 8 of 10
hosneyalaa
in reply to: joshmcdalton

HI

WORKING WITH ME

LIKE THIS

 

Capture0.JPG

 

 

 

Capture.JPG

Message 9 of 10
joshmcdalton
in reply to: hosneyalaa

@hosneyalaa I got it to work when I started another program with just his snippet in it and it worked. I have narrowed down the problem to getting the active civil document. I am just trying to figure out how I am going to do that. As it stands now, I get the active CAD document when the program is run before I open the form. When I do this, I believe it can no longer get the active document until after the form has closed. I will keep working and let you know!
Message 10 of 10
joshmcdalton
in reply to: joshmcdalton

https://forums.autodesk.com/t5/net/autocad-civil3d-unable-to-add-point-groups-after-opening-windows/... I have moved the post to another location because the original cause of the error is not what I speculated in this post.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report