Message 1 of 6

Not applicable
11-07-2018
03:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
In this code I can insert the same block with different distances, dimensions (X Y) and text so there are already 3 lists. Now i want the code also to insert diferent blocks by blockname
Here is the code I want to append the list for blocks in.
(defun c:detectie (/ distcum distlst doc enm obj spc txtlst xylst o p) (vl-load-com) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-endundomark doc) (vla-startundomark doc) (setq distLst '(1.0 11.0 12.0 25.0 )) ; distance detection loop ;;(setq distLst '(1.0 9.0 26.0 11.0 9.0 58.0 100.0 124.0 )) (setq xyLst '((1 2.5) (8 1) (18 1) (1 2) )) ; detection loop size ;;(setq xyLst '((1 2) (20 1) (1 2) (1 2) (1 2) (1 2) (5 1) (5 1) )) (setq txtLst '("D011" "D014" "D017" "D0110" )) ; loop numbers ;;(setq txtLst '("D011" "D012" "D013" "D014" "D015" "D016" "D017" "D018")) (if (and (setq enm (car (entsel "\n >> Select pline >>"))) (setq obj (vlax-ename->vla-object enm)) (= "AcDbPolyline" (vla-get-objectname obj)) (or (< (apply '+ distlst) (vlax-curve-getdistatpoint obj (vlax-curve-getendpoint obj))) (progn (alert "Pline is too short. make pline longer!") nil) ) ) (progn (setvar 'cmdecho 0) (command "_.-insert" "SVW-VRI_KABEL_DETECTIELUS_90-G") (command nil) (setvar 'cmdecho 1) (setq distcum 0) (setq spc (vla-objectidtoobject doc (vla-get-ownerid obj))) (mapcar '(lambda (dist xy txt / ang pt) (setq distcum (+ distcum dist)) (setq ang (angle '(0 0 0) (vlax-curve-getfirstderiv obj (vlax-curve-getparamatdist obj distcum)) ) ) (setq pt (vlax-curve-getpointatdist obj distcum)) (command "setvar" "clayer" "N-WE-VW-VRI_DETECTIELUSSEN") (vlax-invoke spc 'insertblock pt "SVW-VRI_KABEL_DETECTIELUS_90-G" (car xy) (cadr xy) (car xy) ang ) ;; RJP » 2018-11-02 ;; Check that we created the text (command "setvar" "clayer" "N-WE-VW-VRI-T18_DETECTIELUSSEN") (cond ((setq o (vlax-invoke spc 'addtext txt (setq p (polar (polar pt ang (+ (car xy) 1.40)) ; 1.40 distance to block. (+ ang (* 0.0 pi)) -0.225 ; -0.225 distance to pline. ;I want to put this to 0 with alignment middleleft ) ) 0.45 ; Hoogte. ) ) ;; Now apply the properties (vla-put-rotation o ang) (vlax-put o 'alignment 10) (vlax-put o 'textalignmentpoint p) ) ) ) distlst xylst txtlst ) ) ) (vla-endundomark doc) (princ) )
Solved! Go to Solution.