Espernega Posted December 10, 2020 Posted December 10, 2020 (edited) Hi, i'm looking for a lisp to connect cogo points on civil 3d, it can be in 2d or 3d line, i've found this lisp Connectpts.lsp, but it doesn't work on 2021 program. Anyone have a clue on how to change the code to make it work,? thanks ;|Platform: AutoCAD Civil 3D Routine to draw 3dPoly between points with identical descriptions, in ascending Pt# order. by Jeff Mishler, July 25, 2007. Tested only in C3D2008 |; (defun c:Connectpts (/ appstr coords desc grps pline point point#s points pt qbldr ss tmpgrp vrsn ) (VL-LOAD-COM) (setq vrsn (vlax-product-key)) (cond ((vl-string-search "R16.2" vrsn)(setq appstr "3.0"));;2006 ((vl-string-search "R19.0" vrsn)(setq appstr "10.0"));;2013 ((vl-string-search "R19.1" vrsn)(setq appstr "10.3"));;2014 ((vl-string-search "R20.0" vrsn)(setq appstr "10.4"));;2015 ((vl-string-search "R20.1" vrsn)(setq appstr "10.5"));;2016 (t (alert "This version of C3D not supported!")) ) (if (and appstr (or *acad* (setq *acad* (vlax-get-acad-object)) ) (or *AeccApp* (setq *AeccApp* (vla-getinterfaceobject *acad* (strcat "AeccXUiLand.AeccApplication." appstr))) ) (or *AeccDoc* (setq *AeccDoc* (vlax-get *AeccApp* 'ActiveDocument)) ) (setq ss (ssget ":S:E" '((0 . "AECC_COGO_POINT")))) ) (progn (setq pt (vlax-ename->vla-object (ssname ss 0)) desc (vlax-get pt 'RawDescription) grps (vlax-get *AeccDoc* 'PointGroups) tmpgrp (vlax-invoke grps 'Add "__TEMP__") ) (setq qbldr (vlax-get tmpgrp 'querybuilder)) (vlax-put qbldr 'IncludeRawDescriptions desc) (if (> (length (setq points (vlax-get tmpgrp 'Points))) 1) (progn (setq point#s (vl-sort points '<)) (setq points (vlax-get *AeccDoc* 'Points)) (foreach pt# point#s (setq point (vlax-invoke points 'Find pt#)) (setq coords (append coords (list (vlax-get point 'Easting) (vlax-get point 'Northing) (vlax-get point 'Elevation) ))) ) (setq pline (vlax-invoke (vla-get-modelspace *AeccDoc*) 'Add3dPoly coords)) (vla-put-layer pline (vlax-invoke *aeccdoc* 'getvariable "Clayer")) ) ) (vlax-invoke qbldr 'clear) (vlax-invoke grps 'remove "__TEMP__") ) ) (princ) ) Edited December 10, 2020 by SLW210 Added Code Tags Quote
rlx Posted December 10, 2020 Posted December 10, 2020 untested (defun c:Connectpts (/ appstr coords desc grps pline point point#s points pt qbldr ss tmpgrp vrsn) (VL-LOAD-COM) (setq vrsn (vlax-product-key)) (cond ((vl-string-search "R16.2" vrsn) (setq appstr "3.0")) ;;; 2006 ((vl-string-search "R19.0" vrsn) (setq appstr "10.0")) ;;; 2013 ((vl-string-search "R19.1" vrsn) (setq appstr "10.3")) ;;; 2014 ((vl-string-search "R20.0" vrsn) (setq appstr "10.4")) ;;; 2015 ((vl-string-search "R20.1" vrsn) (setq appstr "10.5")) ;;; 2016 ;;; *********** added this line but don't know if "AeccXUiLand.AeccApplication." will accept appstr "10.5" **************** ((vl-string-search "R24.0" vrsn) (setq appstr "10.5")) ;;; 2021 (t (alert "This version of C3D not supported!")) ) (if (and appstr (or *acad* (setq *acad* (vlax-get-acad-object)) ) (or *AeccApp* (setq *AeccApp* (vla-getinterfaceobject *acad* (strcat "AeccXUiLand.AeccApplication." appstr))) ;;;;; ********* this line uses appstr but not sure if it can be tricked in using same code as for acad 2016 ) (or *AeccDoc* (setq *AeccDoc* (vlax-get *AeccApp* 'ActiveDocument)) ) (setq ss (ssget ":S:E" '((0 . "AECC_COGO_POINT")))) ) (progn (setq pt (vlax-ename->vla-object (ssname ss 0)) desc (vlax-get pt 'RawDescription) grps (vlax-get *AeccDoc* 'PointGroups) tmpgrp (vlax-invoke grps 'Add "__TEMP__") ) (setq qbldr (vlax-get tmpgrp 'querybuilder)) (vlax-put qbldr 'IncludeRawDescriptions desc) (if (> (length (setq points (vlax-get tmpgrp 'Points))) 1) (progn (setq point#s (vl-sort points '<)) (setq points (vlax-get *AeccDoc* 'Points)) (foreach pt# point#s (setq point (vlax-invoke points 'Find pt#)) (setq coords (append coords (list (vlax-get point 'Easting) (vlax-get point 'Northing) (vlax-get point 'Elevation) ))) ) (setq pline (vlax-invoke (vla-get-modelspace *AeccDoc*) 'Add3dPoly coords)) (vla-put-layer pline (vlax-invoke *aeccdoc* 'getvariable "Clayer")) ) ) (vlax-invoke qbldr 'clear) (vlax-invoke grps 'remove "__TEMP__") ) ) (princ) ) Quote
BIGAL Posted December 11, 2020 Posted December 11, 2020 Looks like old code that I got from somewhere apologise to original author name not included. ok Type "About" will reveal the number your after. "10.5" is wrong dont have 2021 to check, 24 sounds right. ((vl-string-search "R21.0" vrsn)(setq appstr "11.0"));;2017 ((vl-string-search "R22.0" vrsn)(setq appstr "12.0"));;2018 ((vl-string-search "R23.0" vrsn)(setq appstr "13.0"));;2019 ((vl-string-search "R23.1" vrsn)(setq appstr "13.2"));;2020 The better way is to look at the registery again apologise to original author name not included. (setq acApp (vlax-get-acad-object)) (setq C3D (strcat "HKEY_LOCAL_MACHINE\\" (if vlax-user-product-key (vlax-user-product-key) (vlax-product-key) ) ) C3D (vl-registry-read C3D "Release") C3D (substr C3D 1 (vl-string-search "." C3D (+ (vl-string-search "." C3D) 1)) ) ) (vla-getinterfaceobject acApp (strcat "AeccXUiLand.AeccApplication." C3D) ) (alert (strcat "version is " c3d "\n\n" "product key is " (vlax-product-key))) Quote
tombu Posted December 11, 2020 Posted December 11, 2020 ((vl-string-search "R21.0" vrsn)(setq appstr "11.0"));;2017 ((vl-string-search "R22.0" vrsn)(setq appstr "12.0"));;2018 ((vl-string-search "R23.0" vrsn)(setq appstr "13.0"));;2019 ((vl-string-search "R23.1" vrsn)(setq appstr "13.2"));;2020 ((vl-string-search "R24.0" vrsn)(setq appstr "14.0"));;2021 Maybe, not sure about 14.0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.