Jump to content

Create associative path array with an inserted block


Recommended Posts

Posted (edited)

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:

MyArrayblock.JPG.b6622f5740bb6e220f64191bddb4bc6c.JPG

 

Example of Associated path array using inserted block when successful:

MyArraypath.thumb.JPG.f9f2bda686702341e6a7b03f9f3c8e8e.JPG

 

 

 

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!

MyArray_block.dwg

Edited by RLispLearner
Adding more information
Posted

Did you do another post about using patharray somewhere remember seeing it ? Ok 1st suggestion give up on path array much easier to just use a repeat in a lisp and insert the block aligning along a pline. Thats the way I would do it.

 

You need to post a dwg with real p/line work so can see length of line segments etc. What happens if line length is not a factor of 4 ?

Posted

Thanks for your quick reply! I posted a Dwg with this post. Hopefully you can download it and see the block. Also, it needs to be an associative path array because there is a 95% chance it needs to be altered once created by the user. Pulling on the  grip handles of the associated array allows that change as blocks are either added or reduced when adjusting the line. The path draw is just an initial starting point for the user and then it need to be fine tuned once the array is created. At my office we are doing things manually and it is tedious so looking for a better solution...🙂

Posted

I went ahead and added a DWG file of a random polyline for testing. There should already be a DWG of the block mentioned above.

 

Please Note: The Polyline will have an unknown length because it will be base on a projects specific parameters and every project is different. A line is created to be a close proximity.  Once the Array is created, pulling the grip handles will allow the blocks to fit properly for the length needed as they will be added or removed when adjusted.

Please see attached DWG of a random polyline for testing.

 

Thanks BigAl for your input...!

Random_polyline_for_Array.dwg

Posted (edited)

Ok BIG STEP 1 the insertion point is at wrong point. should be at center of link etc. I will fix for testing. I am still confused what happens if segment length is not 4'. 

 

Is it like this for a solution. A contious repeat of the block correctly aligned 

Forklift.thumb.png.bf7075efaf5a3d301cbb907f1c64b87d.png

 

Is this what happens at change of direction as per forklift image. It was set to 1.5m spacing. I have that code done.

 

Almost there does not use array path. Couple of bugs to fix. Note the vertex point block end i on next segment.

image.thumb.png.f7f2ff6986c0f8464487207a76f25e31.png

Edited by BIGAL
Posted

Thanks BigAl for all your hard work.

 

The blocks wont fit the line most likely the first time. The blocks will be going around a shape and the blocks need to be close to that shape. Shape is based on  the specific project and can change.  Each shape different for each project. The two ends of the line will be "hooked" into another object to complete a "loop" so the blocks need to be adjusted to stop at the end points, but in-between the adjustments can be made to both be as close to the shape in the center but also fit the 4' segments. Like a chain.  Right now, my team is doing this manually and when there are changes to the shape its surrounding, more adjustments are needed. Takes time.  I think if its associative, that would cut down allot of work. More Vertex points will most likely need to be created so grab handles can be "snapped" to the 4' segments but that would be quicker than manually adjusting. . The horseshoe  shape in my drawing is somewhat typical for a project. I would first make my poly line go around the shape and  "hook" into an object on both ends to complete the loop. Next do the array and then adjust the line to fit the segments. It will also make updates quicker if there are changes to the shape...Trying to take something tedious and hopefully make it easier. Thanks again! 🙂

Posted (edited)

Please post a completed dwg still struggling to understand what you want, provide a couple of examples. Show steps in getting to final answer.

 

" Like a chain." that is what I did. 

Edited by BIGAL
Posted

Thanks for your help. I will work on posting a mock up dwg with steps included....🙂

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...