Search the Community
Showing results for tags 'cogo points'.
-
Aotomatic cogo point import from csv file
benlconstructors posted a topic in AutoLISP, Visual LISP & DCL
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- 15 replies
-
- lisp
- cogo points
-
(and 2 more)
Tagged with:
-
There I was, fooling around in the CUI window adding panels to my Home ribbon, then when I was through, I noticed all my points disappeared. Trying to figure out what went wrong, I learned; 1. my points are not missing, just not visible in the model tab. They exist, they show up in toolspace>points, and in layout views. 2. they are as if they are on a frozen layer. I can't see them and I can't select them with a cursor window, but I can select them with qselect, which I know they are selected because it tells me so on the command line. 3. not all points are gone from sight in the model tab, just the ones which were on and thawed while I was tinkering with CUI. If it was vice-versa, i.e. I could see them in the model but not in a viewport I could blame it on viewport freeze, but not so. I messed with PDMODE and PDSIZE, of course to no avail. I am working in Civil 3D 2010 and more than a little baffled. Thanks, Bill
- 2 replies
-
- cogo points
- model
-
(and 1 more)
Tagged with: