Search the Community
Showing results for tags 'extract od'.
jes_g posted a topic in AutoLISP, Visual LISP & DCLHi all, I'm trying write a LISP routine which will accomplish the following: 1. Select the block reference on the drawing 2. Find the closest polyline and closest point on that polyline from this block reference 3. Create vertex on that point and save the coordinates of this point into a variable for further use 4. Extract Object Data such as SerialNo (please refer to the screenshot attached) from that block reference 5. Loop for each block reference 6. Export the point's coordinates saved earlier and its corresponding SerialNo into txt or csv which will look like: X_coord, Y_coord, SerialNo E.g. 85.4535, 18.7903, 09I4E5Q2104022719 or 85.4535, 18.7903, 09I4E5Q2104022311, 09I4E5Q2104022719 (if it has more than one block reference) The output file is interpreted as the electric line having the load on that particular point. Here's what I have found/borrowed so far which can be of help: For creating vertex program provided by DEVITG at this thread ;; Design by Gabo CALOS DE VIT from CORDOBA ARGENTINA ;;; Copyleft 1995-2018 by Gabriel Calos De Vit ;; DEVITG@GMAIL.COM ; Hecho por Gabo CALOS DE VIT de CORDOBA ARGENTINA ;;; Copyleft 1995-2018 por Gabriel Calos De Vit ;; DEVITG@GMAIL.COM ; no error check. ;; no nothing (vl-load-com) (DEFUN C:EXAMPLE_ADDVERTEX ( / ACADOBJ BLK-REF-XYZ BLK-REFERENCE DOC LSTPOINT MODELSPACE NEWVERTEX PARAM-AT-CLOSEST-POINT PLINE PLINE-OBJ POINT-AT-PARAM VERTEX-POINT ) (SETQ ACADOBJ (VLAX-GET-ACAD-OBJECT)) (SETQ DOC (VLA-GET-ACTIVEDOCUMENT ACADOBJ)) (SETQ MODELSPACE (VLA-GET-MODELSPACE DOC)) (SETQ PLINE (ENTSEL "\nSelect Polyline: ")) (SETQ PLINE-OBJ (VLAX-ENAME->VLA-OBJECT (CAR PLINE))) (SETQ BLK-REFERENCE (CAR (ENTSEL "\Select the block-reference"))) (SETQ BLK-REF-XYZ (CDR (ASSOC 10 (ENTGET BLK-REFERENCE)))) ;;; (VL-CMDF "POINT" BLK-REF-XYZ "") (SETQ LSTPOINT (VLAX-CURVE-GETCLOSESTPOINTTO PLINE-OBJ BLK-REF-XYZ)) (SETQ PARAM-AT-CLOSEST-POINT (VLAX-CURVE-GETPARAMATPOINT PLINE-OBJ LSTPOINT)) (SETQ POINT-AT-PARAM (VLAX-CURVE-GETPOINTATPARAM PLINE-OBJ PARAM-AT-CLOSEST-POINT)) (SETQ VERTEX-POINT (LIST (CAR POINT-AT-PARAM) (CADR POINT-AT-PARAM))) ;;; (VL-CMDF "POINT" VERTEX-POINT "") (SETQ NEWVERTEX (VLAX-MAKE-SAFEARRAY VLAX-VBDOUBLE '(0 . 1))) (VLAX-SAFEARRAY-FILL NEWVERTEX VERTEX-POINT) (VLA-ADDVERTEX PLINE-OBJ (1+ (FIX PARAM-AT-CLOSEST-POINT)) NEWVERTEX) (VLA-UPDATE PLINE-OBJ) ) It works good but now it needs to be modified to work in a loop For extracting Object Data the answer provided by BlackBox at this thread might be helpful The Sample Drawing is attached I would appreciate your help Thank you Regards, Jes G Sample_Drawing.dwg