Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

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

joshmcdalton
Contributor
Contributor

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

joshmcdalton
Contributor
Contributor

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)

0 Likes
Reply
Accepted solutions (1)
977 Views
9 Replies
Replies (9)

hosneyalaa
Advisor
Advisor
0 Likes

joshmcdalton
Contributor
Contributor
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...
0 Likes

hosneyalaa
Advisor
Advisor

Hi @joshmcdalton 

 Never tried it before

But try to be a .txt file

 and not .csv file 

 

 

 

0 Likes

joshmcdalton
Contributor
Contributor
Unfortunately, I get the same error
0 Likes

hosneyalaa
Advisor
Advisor

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

0 Likes

joshmcdalton
Contributor
Contributor
I cannot, I still get no points transferred from file.
Thanks
0 Likes

hosneyalaa
Advisor
Advisor

HI

WORKING WITH ME

LIKE THIS

 

Capture0.JPG

 

 

 

Capture.JPG

0 Likes

joshmcdalton
Contributor
Contributor
@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!
0 Likes

joshmcdalton
Contributor
Contributor
Accepted solution
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.
0 Likes