Jump to content

Selecting an Object while using the Array command....


CaddJax

Recommended Posts

Hi all, and thanks in advance for checking this out.

 

I'm finally biting the bullet and attempting to write some code for some of the more repetitive aspects of the work I do. Problem is that I'm having to reverse engineer others' script to try and get done what I want, and I've been unsuccessful finding it.

 

Lee, I've been to your site and didn't find what I need, so if you have it, great, if not, I'll give you this one when I'm done.

 

Here's the basic purpose: Wall Panels. I'm writing a code that will ask the user to select a wall (point to point), enter a panel height and the panel's height AAF. The program will take those inputs and fill the wall with an equal number of panels not to exceed 48"W.

 

As I get the first part down, Plan B is to convert the polylines to blocks, query for reveals, etc.... But for now, I'm still learning to crawl.

 

I can't seem to figure out how to select the polyline after it's drawn to use it in the array. I know it has to be a pretty simple fix, but I can't seem to figure it out. The dilemma is that there is no set point in model space, so the coordinates to use for selection will have to be based off of the initial starting point of the first panel. (this is the first run, so I haven't entered code for user input yet)

 

If someone will help me through just this bit, It'd be much appreciated.

 

Code is as follows: (the rtos is the last thing I was trying to play with, but can't get it to work either. What I used to test out the first part is below)

 

(defun DP ()

 

(setq WL (getreal "\nEnter Length of Wall: "))

 

(setq NP (fix (if

(> (/ WL 48 ) (fix (/ WL 48 )))

(+ (fix (/ WL 48 )) 1)

(/ WL 48 ))))

(setq PW (/ WL NP))

 

(setq ph (getreal "\nEnter Height of Panel: "))

(setq ps (getpoint "\Select Start Point of Panels: "))

 

(command "rectangle" ps "d" PW ph ps)

 

(setq pp1 (rtos ((- (car ps) 1))))

(setq pp2 (rtos ((- (cadr ps) 1))))

(setq pp1b (rtos (+ (car ps) PW 1)))

(setq pp2b (rtos (+ (cadr ps) PH 1 )))

 

 

(command "-array" "w" 'pp1,pp2 'pp1b,pp2b "" "R" 1 NP PW)

 

(princ)

)

 

This is what I was using just to make sure the code worked, but it's not feasible since it relies on set coordinates.

 

(command "rectangle" ps "d" PW ph ps)

(command "-array" "w" "-14664,18648" "-14388,18720" "" "R" 1 NP PW)

 

(princ)

)

Link to comment
Share on other sites

Hi CaddJax,

 

I'm using BricsCAD now but I think this should work for you. In array, instead of using "W" use "L" for last entity. In your code I changed that, took out a couple of extra parentheses in your pp1 and pp2 lines, used (rtos PW) and (rtos ph) in the rectangle command and then it ran for me. There are other ways to select the last entity, but give this a try.

 

(defun C:DP ()

(setq WL (getreal "\nEnter Length of Wall: "))

(setq NP (fix (if
(> (/ WL 48 ) (fix (/ WL 48 )))
(+ (fix (/ WL 48 )) 1)
(/ WL 48 ))))
(setq PW (/ WL NP))

(setq ph (getreal "\nEnter Height of Panel: "))
(setq ps (getpoint "\Select Start Point of Panels: "))

(command "rectangle" ps "d" (rtos PW) (rtos ph) ps)

(setq pp1 (rtos (- (car ps) 1)))
(setq pp2 (rtos (- (cadr ps) 1)))
(setq pp1b (rtos (+ (car ps) PW 1)))
(setq pp2b (rtos (+ (cadr ps) PH 1)))


(command "-array" "L" 'pp1,pp2 'pp1b,pp2b "" "R" 1 NP PW)

(princ)
)

Link to comment
Share on other sites

my suggestion

(setq WL (getreal "\nEnter Length of Wall: "))

: replace with

(setq pt1 (getpoint "\Pick Start of wall "))

(setq pt2 (getpoint "\Pick End of wall "))

(setq WL (distance pt1 pt2))

 

;(setq ps (getpoint "\Select Start Point of Panels: ")) not required as you can use pt1

[\code]

 

A couple more suggestions what happens when wall is on an angle ? Just me but the way I have done these is to also get the angle of the line generally I use repeat rather than array and use copy.

 

Also you need a remainder panel, there is different ideas on this one only or two small one at start and one at end.

Link to comment
Share on other sites

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...