Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/07/2024 in all areas

  1. (defun c:zoo () ;; also, you can localized the all variables from code (/ pt) to be set as default (nil) before next execution. ;; (if (setq a (entlast)) ;; (while ;; (setq b (entnext a)) ;; (setq a b) ;; ) ;;) ;;(setq ent (entget a)) ;;(setq po (assoc 10 ent)) ;;(setq pt (cdr po)) (setq pt (cdr (assoc 10 (entget (entlast))))) ;; this line substitue the 9 lines of code from above. ;;(command "zoom" "c" pt 50 "") --> delete the last "" after 50, because you are calling again "zoo" command (command "zoom" "c" pt 50) ) I put a some description in your code, hope it will be helpful.
    1 point
  2. This is what I came up with. I call the command 'FLINT' for feature line intersection. Prompts user to select a featureline. It then finds what site it belongs to and all other featurelines that belong to the same site. It finds the intersections using the intersectwith method and then inserts ElevationPoints on both the selected featureline and the featureline that was intersected. The elevation as to which the ElevationPoint is set appears to be rather random, but the point was to automatically add ElevationPoints at the intersections. A prompt could be added to have the user enter the elevation for the inserted point. Give this a test and let me know what you think. regards, hippe013 (defun c:FLINT ( / fl site fls p-count sa catch n proc) (setq ss (ssget "_+.:E:S" '((0 . "AECC_FEATURE_LINE")))) (if ss (progn (setq fl (vlax-ename->vla-object (ssname ss 0))) (setq site (FL:FL->site fl)) (setq fls (vlax-get-property site 'Featurelines)) (setq p-count 0) (vlax-for f fls (if (not (equal f fl)) (progn (setq sa (vlax-variant-value (vlax-invoke-method fl 'IntersectWith f acExtendNone))) (setq catch (vl-catch-all-apply 'vlax-safearray->list (list sa))) (if (not (vl-catch-all-error-p catch)) (progn (setq catch (fl:list->pntlist catch)) (setq n 0) (repeat (length catch) (setq p (nth n catch)) (if (not (member p proc)) (progn ;Use 2 for Elevation Point - Use 1 for PI (vlax-invoke-method fl 'InsertFeaturePoint (vlax-3d-point p) 2) (vlax-invoke-method f 'InsertFeaturePoint (vlax-3d-point p) 2) (fl:drx p 2) (setq proc (append proc (list p))) (setq p-count (+ p-count 2)) ) ) (setq n (+ n 1)) ) ) (progn) ) ) ) ) (princ (strcat "\nInserted " (itoa p-count) " Elevation Points.")) ) (princ "\nNothing was Selected.") ) (princ) ) (defun FL:Site->FL-ID-List (site / fls cnt ret n li) (setq fls (vlax-get-property site 'Featurelines)) (setq cnt (vlax-get-property fls 'Count)) (if (= cnt 0) (setq ret nil) (progn (setq n 0) (repeat cnt (setq li (append li (list (vlax-get-property (vla-item fls n) 'ObjectID)))) (setq n (1+ n)) ) (setq ret li) ) ) ret ) (defun FL:List->pntlist (li / newli) (setq n 0) (repeat (/ (length li) 3) (setq newli (append newli (list (list (nth n li) (nth (+ n 1) li) (nth (+ n 2) li))))) (setq n (+ n 3)) ) newli) (defun FL:FL->Site (fl / cvlapp cvlad sites ret n site objid-list ) (setq cvlapp (vlax-get-property fl 'application)) (setq cvlad (vlax-get-property cvlapp 'ActiveDocument)) (setq sites (vlax-get-property cvlad 'Sites)) (setq ret nil) (setq n 0) (repeat (vlax-get-property sites 'Count) (setq site (vla-item sites n)) (setq objid-list (FL:Site->FL-ID-List site)) (if (member (vlax-get-property fl 'ObjectID) objid-list) (setq ret site) ) (setq n (1+ n)) ) ret ) (defun FL:drx (ctr clr / cor1 cor2 cor3 cor4 vs xs) (setq vs (getvar "viewsize")) (setq xs (/ vs 40)) (setq cor1 (polar ctr (* pi 0.25) xs)) (setq cor2 (polar ctr (* pi 0.75) xs)) (setq cor3 (polar ctr (* pi 1.25) xs)) (setq cor4 (polar ctr (* pi 1.75) xs)) (grdraw ctr cor1 clr 0) (grdraw ctr cor2 clr 0) (grdraw ctr cor3 clr 0) (grdraw ctr cor4 clr 0) )
    1 point
×
×
  • Create New...