;;----------------------------------------------------------------------- ;; Add_CGPoint.lsp (c) 2003, John F. Uhden, Cadlantic/CADvant.age ;; ;; Function to add a Land Desktop CogoPoint object taking two arguments. ;; Arguments: ;; Point - a list of two or more Reals representing the coordinate point ;; Format - an integer (1 or 2) representing the coordinate format ;; 1 - Point is in Easting, Northing, elevation ;; 2 - Point is in X, Y, elevation. AutoCAD coordinates ;; Returns: ;; The VLA-Object of the newly added CogoPoint if successful, or ;; nil if unsuccessful ;; Notes: ;; If the Point list has only 2 elements, no elevation will be assigned. ;; There is no control of the point number, description, insertion layer, ;; display, or grouping in this example. (defun Add_CGpoint (Point Format / AeccApp Project Points Var Object) (vl-load-com) (if (not *acad*)(setq *acad* (vlax-get-acad-object))) (and (setq AeccApp (vl-catch-all-apply 'vla-getinterfaceobject (list *acad* "aecc.application") ) ) (or (not (vl-catch-all-error-p AeccApp)) (prompt "\nLand Desktop Cogo application not loaded.") ) (vlax-property-available-p AeccApp 'ActiveProject) (or (setq Project (vlax-get-property AeccApp 'ActiveProject)) (prompt "\nThere is no active project.") ) (vlax-property-available-p Project 'CogoPoints) (or (setq Points (vlax-get-property Project 'CogoPoints)) (prompt "\nCogo Points not available.") ) (or (and (listp Point) (> (vl-list-length Point) 1) (vl-every 'numberp Point) (<= (vl-list-length Point) 3) (setq Var (vlax-make-safearray vlax-vbDouble (cons 0 (1- (length Point))) ) ) (vlax-safearray-fill Var Point) (setq Var (vlax-make-variant Var 8197)) ) (prompt "\nInvalid point coordinate data.") ) (or (vl-position Format '(1 2)) (prompt "\nInvalid format code (1=ENZ, 2=XYZ)") ) (or (not (vl-catch-all-error-p (setq Object (vl-catch-all-apply 'vla-add (list Points Var Format) ) ) ) ) (setq Object (prompt (vl-catch-all-error-message Object))) ) ) Object ) (defun Delete_CGpoint (# / Project Points Point) (vl-load-com) (or (setq *acad* (vlax-get-acad-object))) (and (or AeccApp (setq AeccApp (vl-catch-all-apply 'vla-getinterfaceobject (list *acad* "aecc.application") ) ) ) (or (not (vl-catch-all-error-p AeccApp)) (prompt "\nLand Desktop Cogo application not loaded.") ) (vlax-property-available-p AeccApp 'ActiveProject) (or (setq Project (vlax-get AeccApp 'ActiveProject)) (prompt "\nThere is no active project.") ) (vlax-property-available-p Project 'CogoPoints) (or (setq Points (vlax-get-property Project 'CogoPoints)) (prompt "\nCogo Points not available.") ) (setq Point (vl-catch-all-apply 'vlax-invoke (list Points 'PointByNumber #))) (not (vl-catch-all-error-p Point)) (or (/= (vlax-get Point 'LockType ) 1) (prompt (strcat "\nPoint number " (itoa #) " is locked.")) ) (not (vlax-invoke Points 'Delete #)) ) )