Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey everyone,
New at writing routines, and especially new at utilizing the ActiveX extensions... so bear with me. Currently getting an "error: bad argument type for compare: XVAL XVAL" when I run the routine.
Tried to comment in my intentions with what the code is supposed to do.
Goal is to be able to insert a user-specified block at horizontal spacing along a polyline. Figured I would utilize the the Lee-Mac extension intersection code to use it.
Thanks for looking/helping.
(vl-load-com);load activeX functionality ;*****Start of intersections function***** ;; Intersections - Lee Mac ;; Returns a list of all points of intersection between two objects ;; for the given intersection mode. ;; ob1,ob2 - [vla] VLA-Objects ;; mod - [int] acextendoption enum of intersectwith method (defun LM:intersections ( ob1 ob2 mod / lst rtn ) (if (and (vlax-method-applicable-p ob1 'intersectwith) (vlax-method-applicable-p ob2 'intersectwith) (setq lst (vlax-invoke ob1 'intersectwith ob2 mod)) ) (repeat (/ (length lst) 3) (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn) lst (cdddr lst) ) ) ) (reverse rtn) ) ;*****Start of hspaceblock function***** (defun c:hspaceblock (/ oldsnap oldortho oldlayer pol polobj space blname inc xval yval listx listy minxval maxxval linexval pntlist point1 point2 currentline intsxpnt) ; all local variables ;Save System Variables (setq oldsnap (getvar "osmode")) ;save snap settings (setq oldortho (getvar "orthomode")) ;save orthomode settings (setq oldlayer (getvar "clayer")) ;save layer ;Turn System Variables Off (setvar "osmode" 0) (setvar "orthomode" 0) ;layer gets changed in coding below ;Select plolyline (setq pol (car (entsel "\nSelect Polyline: "))) (setq polobj (vlax-ename->vla-object pol)) ;Set Distance (setq space (getint "\nPlease enter horizontal spacing: ")) (setq blname (getstring "\nPlease enter name of block: ")) ;draw small lines at polyline points, get intersection of bottom of polyline (setq inc 0) ;set increment to 0 (while (<= inc (vlax-curve-getEndParam polobj)) ;progress through number of vertices (setq xval (car (vlax-curve-getPointAtParam polobj inc))) ;get x value of polyline vertex (setq yval (cadr (vlax-curve-getPointAtParam polobj inc))) ;get y value of polyline vertex (setq listx (append listx '(xval))) ;add x to listx (setq listy (append listy '(yval))) ;add y to listy ;increase increment for next polyline point (setq inc (1+ inc)) ) (setq minxval (car listx)) ;first value of listx (setq maxxval (last listx)) ;last value of listx (setq linexval minxval) ;set initial line x value (setq pntlist nil) ;instantiates a point list (setq inc 0) ;creates inc to 0 (command "-LAYER" "SET" "CONSTRUCT" "");set layer to construct (while (< linexval maxxval) ;progress through number of ranges (setq point1 '(linexval yval)) ;set initial point at linexval for x value and yval from above...should be yvalue of last vertex in polyline (setq point2 '(linexval (- yval 0.01))) ;set final point at linexval for x value and a small distance down from yval (command "LINE" point1 point2);draw line (setq currentline (entlast));set last drawn line to currentline (setq intsxpnt (LM:intersections (polobj) (vlax-ename->vla-object currentline) acExtendOtherEntity)) ;above sets currentline to VLA object, finds the intersection if currentline is extended to polobj and returns that point (command "-INSERT" blname intsxpt "" "") ;insert user-specified block at intscpnt at 1 scale and no rotation (setq linxval (+ linxval space));add space to linexval and then go to while loop ) ;Restore System Variables (setvar "osmode" oldsnap) (setvar "orthomode" oldortho) (setvar "clayer" oldlayer) (princ);print cleanly );end of definition
Solved! Go to Solution.