Jump to content

Search the Community

Showing results for tags 'import points'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • CADTutor
    • News, Announcements & FAQ
    • Feedback
  • AutoCAD
    • AutoCAD Beginners' Area
    • AutoCAD 2D Drafting, Object Properties & Interface
    • AutoCAD Drawing Management & Output
    • AutoCAD 3D Modelling & Rendering
    • AutoCAD Vertical Products
    • AutoCAD LT
    • CAD Management
    • AutoCAD Bugs, Error Messages & Quirks
    • AutoCAD General
    • AutoCAD Blogs
  • AutoCAD Customization
    • The CUI, Hatches, Linetypes, Scripts & Macros
    • AutoLISP, Visual LISP & DCL
    • .NET, ObjectARX & VBA
    • Application Beta Testing
    • Application Archive
  • Other Autodesk Products
    • Autodesk 3ds Max
    • Autodesk Revit
    • Autodesk Inventor
    • Autodesk Software General
  • Other CAD Products
    • BricsCAD
    • SketchUp
    • Rhino
    • SolidWorks
    • MicroStation
    • Design Software
    • Catch All
  • Resources
    • Tutorials & Tips'n'Tricks
    • AutoCAD Museum
    • Blocks, Images, Models & Materials
    • Useful Links
  • Community
    • Introduce Yourself
    • Showcase
    • Work In Progress
    • Jobs & Training
    • Chat
    • Competitions

Categories

  • Programs and Scripts
  • 2D AutoCAD Blocks
  • 3D AutoCAD Blocks
  • Images
    • Backgrounds

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Found 1 result

  1. used chatgpt to get me this code but it generates this error "error: Automation Error. Problem in loading application" any ideas? (defun c:MGC ( / filePath fileLine fileHandle parts ptNum north east elev desc fileName newLayerName acadApp doc layMan layObj civApp civDoc pointsObj groupColl newGroup lastPoint centerPt lineCount existingGroup) ;; Step 1: Open file (setq filePath (getfiled "Select CSV File" "" "csv" 0)) (if (not filePath) (progn (alert "No file selected.") (exit) ) ) ;; Step 2: Save file name (setq fileName (vl-filename-base filePath)) ;; Step 3: Create new layer (setq newLayerName (strcat "Points - " fileName)) (setq acadApp (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadApp)) (setq layMan (vla-get-Layers doc)) (if (not (tblsearch "LAYER" newLayerName)) (progn (setq layObj (vla-Add layMan newLayerName)) (vla-put-Color layObj 3) ) ) ;; Step 4: Make new layer active (vla-put-ActiveLayer doc (vla-Item layMan newLayerName)) ;; Step 5: Civil 3D setup + Point Group (setq civApp (vla-getInterfaceObject acadApp "AeccXUiLand.AeccApplication.24")) (setq civDoc (vla-get-ActiveDocument civApp)) (setq groupColl (vla-get-PointGroups civDoc)) ;; Delete existing group with same name if it exists (vlax-for g groupColl (if (= (strcase (vla-get-Name g)) (strcase fileName)) (vla-Delete g) ) ) ;; Create new group (setq newGroup (vla-Add groupColl fileName)) (vla-put-IncludeAllPoints newGroup :vlax-true) ;; Step 6: Read and import points (setq pointsObj (vla-get-Points (vla-get-Points civDoc))) (setq fileHandle (open filePath "r")) (if (not fileHandle) (progn (alert "Unable to open the selected file.") (exit) ) ) (setq lineCount 0) (while (setq fileLine (read-line fileHandle)) (setq parts (vl-string->list fileLine ",")) (if (>= (length parts) 5) (progn (setq ptNum (nth 0 parts)) (setq north (atof (nth 1 parts))) (setq east (atof (nth 2 parts))) (setq elev (atof (nth 3 parts))) (setq desc (nth 4 parts)) (setq lastPoint (vlax-3d-point (list east north elev))) (vla-Add pointsObj lastPoint desc) (setq lineCount (1+ lineCount)) ) ) ) (close fileHandle) ;; Warn if no valid points were imported (if (= lineCount 0) (alert "No valid points were imported. Please check the file format.") ) ;; Step 7: Zoom to last point (if lastPoint (progn (setq centerPt (vlax-get lastPoint 'Coordinates)) (vla-ZoomCenter acadApp (vlax-3d-point (list (car centerPt) (cadr centerPt) 0)) 50.0) ) ) (princ) ) MGC.lsp
×
×
  • Create New...