- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Good evening,
I'm in the process of building a routine that will allow a user to quickly draw a roof layout. Most of the code has been adapted from other LISP routines found around the web, so I know there are probably redundancies and issues with the code. The main routine, ROLLG, is meant to do the bulk of the routine. AutoCAD 2020, windows 10.
To test the functionality, these parameters would work:
Enter type of material: DL
Enhanced perimeter?: 5
Building Height?: 50
Parapet Height?: 50
After entering those parameters, and selecting the left and right sides of a rectangle (exploded), the user can offset a series of lines towards the inside of the rectangle, so that there is a series of adjacent parallel lines. After that, I am trying to tie together another LISP routine (RollG-Array) that allows a user to have an array of parallel lines populate in the center of the rectangle (every 60 inches)
When I try to insert the Rollg-Array code at the end of the Rollg code, it doesn't want to run the code in the Rollg-Array... I'm guessing there are errors with the main piece of code. Is there anybody that could help me out with this issue?
Thanks!
Here is the RollG code:
(defun c:EWC (/) (c:RollG)) (defun c:RollG (/ *error* AT:Offset #SS #Pnt #Temp #Inc *OO:Del* *OO:Cur* *OO:Num* ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SUBROUTINES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; error handler (defun *error* (#Message) (and *AcadDoc* (vla-endundomark *AcadDoc*)) (and #Message (not (wcmatch (strcase #Message) "*BREAK*,*CANCEL*,*QUIT*")) (princ (strcat "\nError: " #Message)) ) ;_ and ) ;_ defun ;;; Offset selected object ;;; O - Object to offset ;;; D - Distance to offset object ;;; P - Point on side of object to offset (defun AT:Offset (O D P / _pt p1 p2 c D g) (setq _pt (lambda (s) (vlax-curve-getPointAtDist O (s (vlax-curve-getDistAtPoint O p1) 0.00001))) ) ;_ setq (if (and (setq p1 (vlax-curve-getclosestpointtoprojection O (trans P 1 0) '(0 0 1))) (or (setq p2 (setq c (_pt +))) (setq p2 (_pt -))) (if (minusp (- (* (- (car p2) (car p1)) (- (cadr (trans P 1 0)) (cadr p1))) (* (- (cadr p2) (cadr p1)) (- (car (trans P 1 0)) (car p1))) ) ;_ - ) ;_ minusp (if (vl-position (vla-get-objectname O) '("AcDbLine" "AcDbXline")) (setq D (- (abs D))) (setq D (abs D)) ) ;_ if (if (vl-position (vla-get-objectname O) '("AcDbLine" "AcDbXline")) (setq D (abs D)) (setq D (- (abs D))) ) ;_ if ) ;_ if (or c (setq D (- D))) (not (vl-catch-all-error-p (setq g (vl-catch-all-apply 'vla-offset (list O D))))) ) ;_ and (car (vlax-safearray->list (vlax-variant-value g))) ) ;_ if ) ;_ defun ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN ROUTINE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Get User Inputs (initget "DL DT") (if (setq MAT (getkword "\nEnter type of material [DL/DT]: ")) (if (= MAT "DT") (progn (initget "5 10") (setq ROLLSIZE (getint "\nEnter Roll Size [5/10]: ")) ) (progn (setq ROLLSIZE 5) ) );end if );end if (setq EP (getreal "\nEnhanced Perimeter? (Ft) : ")) ;get the enhanced perimeter based off of the windcalc dimension (setq BH (getint "\nBuilding Height? (Ft) : ")) ;get the building height (setq PP (getint "\nParapet Height? (inches) : ")) ;get the parapet height ;**************************************************************** ;command process ;; Global variables (or *OO:Dist* (setq *OO:Dist* 1.)) (or *OO:Del* (setq *OO:Del* "No")) ;local (or *OO:Cur* (setq *OO:Cur* "Yes")) ;local (or *OO:Num* (setq *OO:Num* 1)) ;local (or *OO:Side* (setq *OO:Side* "Single")) (or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) (vla-startundomark *AcadDoc*) (cond ((and (>= BH 40) (< BH 80) (cond ((and (setq #SS (ssget "_:L" '((0 . "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,SPLINE,XLINE")))) (cond ((eq *OO:Side* "Single") (setq #Pnt (getpoint "\nSpecify point on side to offset: "))) ((eq *OO:Side* "Both") T) ) ;_ cond ) ;_ and (vlax-for x (setq #SS (vla-get-activeselectionset *AcadDoc*)) (setq #Inc 0.) (setq #Inc (1+ #Inc)) (cond ((eq *OO:Side* "Single") (and (setq #Temp (AT:Offset x (* #Inc 26) #Pnt)) (AT:Offset x (* #Inc 52) #Pnt)) (AT:Offset x (* #Inc (* EP 12)) #Pnt)));ENHANCED PERIMETER (CONVERTED TO FEET) (command "chprop" (entlast) "" "c" "1" "lt" "Continuous" "") ) ;_ and ) ) ;_ cond ) ;_ vlax-for ) ;_ cond (prompt "\nSelect the RIGHT side of the field: ") (setq ss1 (ssget)) (setq a_path (car (entsel "\nSelect array path: "))) );_cond ) ;_ defun
Here is the RollG-Array code:
(defun c:ap10 ( / ss1 a_path) (setvar "cmdecho" 0) (prompt "\nSelect wall on RIGHT side: ") (setq ss1 (ssget)) (setq a_path (car (entsel "\nSelect array path: "))) (if (and ss1 a_path) (command "_arraypath" ss1 "" a_path "" "" "" "_F" "60" "" "") (princ "\nNo array created!") ) (princ) )
Solved! Go to Solution.