- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
Trying to create a routine for a Path Array but routine wont even load to test. Looking for some help...
Goal:
Create an associative Path Array using a block from an inserted drawing (MyArray_block.dwg).
NOTE: I just have the drawing saved on my desktop so the path will need updating to match your address bar if you test it. Also, I created a DWG file with a random polyline for testing called (Random_polyline_for_Array.dwg).
Steps:
-User either selects an existing Poly line OR creates a new one for the block to be arrayed to. The line will be based on the parameters of the given project so the length will not be know. Therefor the array must be adjustable.
-A drawing containing a block is then inserted and the block is then aligned to the Array Poly line at the start point.
-An associative array is created using the block at a distance of 4 feet apart. blocks will overlap. Length will be unknown which is why it needs to be associative. It can then be adjusted using the grip handle until it fits the project parameters.
Please see illustrations attached:
My block:
Example of a successful Path Array using this block and a random Polyline:
My Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;; User selects or creates Associative path array using an inserted block;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun C:myarray (/ ln_sel arrayline StartPoint insertpt1 myarrayblock myangle mydistance blksecpoint);;
(vl-load-com)
(setq oldLUNITS (getvar "LUNITS"))
;Set Units to Architectural.
(setvar "LUNITS" 4)
;Say YES to Polyine edits automatically.
(setvar "PEDITACCEPT" 1)
;Tell user to select an existing polyline or create a new polyline
(princ "\nSelect an existing Polyline or create a new one: ");command prompt
;User selects existing polyline or draws a new polyline for Associative Path Array. Next, Get start point of that Polyline.
(setq ln_sel (car(entsel "\n Select a polyline:")))
(if (= (cdr(assoc 0 element)) "POLYLINE")
(progn
(setq arrayline (vlax-ename->vla-object (car ln_sel )));User saves Polyline
(setq StartPoint (vlax-curve-getStartPoint arrayline ));save start point
);Else
(command "_pline" pause); If no poyline selected, User draws a polyline
(setq ln_sel (entget "L" ));save Polyline user either selected or creates
(setq StartPoint (vlax-curve-getStartPoint arrayline )); save start point of array path Polyline
);end progn
);end IF
;NEXT
;Insert block from a drawing. Insertion point same location as startpoint of the Associative Path Array Polyline
(setq insertpt1 StartPoint)
(command "_insert" "C:\\Users\\B\\Desktop\\MyArray_block.dwg" insertpt1 "" "" "");Insert drawing (saved on desktop for testing purposes)
(setq myarrayblock (ssget "L" )); save the block that was just inserted into drawing
;Preset my second point variables for my inserted block. Picking opposite end
(setq myangle (atoi "90")); Angle = 90 degrees from start point
(setq mydistance (atoi "48")); Distance = 48" (4') from start point
;Make the second known point on block 48 inches at 90 degrees from insert (or start) point
(setq blksecpoint (polar insertpt1 (angle myangle) mydistance)); point one is insertion or start point. Point two is 48" at 90 degree angle
;Now align the block
;Align the block to the Path Array using set points on block
(if (and (setq blkp1 StartPoint);block insertion point
(setq blkp3 blksecpoint); second point on block. 48" distance at 90 angle.
(setq blkent myarrayblock);inserted block
(setq blkp2 StartPoint); Second alignment point is same as start point (or rotation point)
(setq blkp4 (osnap (cadr blkent) "_nea")); snap second block point somewhere on array path polyline
)
(command "_.align" blkent "" "_non" blkp1 "_non" blkp2 "_non" blkp3 "_non" blkp4 "" "_No")
);End if
;Next, Path Array
;Next do an associative path array using the inserted block that has been aligned
(command "arraypath" blkent "" ln_sel "as" "yes" "items" mydistance "" "");; pick Block. Pick line. Distance 48" (4')
;Last, delete the insert block from the drawing
(if (/= blkent nil)(command "erase" blkent ""))
(setvar "LUNITS" oldLUNITS)
);end
Any assistance or suggestions are greatly appreciated!!!
Thanks all
Solved! Go to Solution.