Jump to content

Help With Trim Command (Looping)


Recommended Posts

Posted

I have a program which in order to assist with you will need to understand is a completely automated routine. Any solution for this cannot involve user input in any way. Most of it is working very well, but I've hit a snag at one point with the trim command.

 

I have a series of rectangles which get drawn in by the code. At any given time the code is run the number of rectangles and their on center spacing will change but the program knows this information and it's stored in variables which can be called. Through these vertical rectangles passes a horizontal line. I need to trim that line so that it does not show up at the interiors of these rectangles. See the attached image file for more detail.

 

My algorithm for determining how to draw in the required number of rectangles as well as the horizontal line is working fine. I should mention that all the rectangles and the horizontal line will always be in the same relation to each other, that is the horizontal line will always be a fixed distance from the top of the rectangles. That's why I used a repeat loop to draw the rectangles in the drawing.

 

I can run the trim command and at least get the first trim operation to complete. And I guess I could run the repeat or while loop until I get each one done. But this is subject to the zoom level as well as I have to set the pickbox to zero to get it to select without grabbing too much of the rectangle.

 

I was thinking more of an array of points which could be setup prior to starting the trim command. But my experience with VLISP gets confused with VBA where variables can be set as an array X(1), X(2), X(3)....etc...which as I understand is not possible in VLISP. I am thinking of another way to do this but it's not as easy as one would think at first glance. I could also leave out the continuous line and then loop through something that would individually draw each segment from the aforementioned known variables. But I was really hoping to make this less brutal.

 

Any advice from the forum on how I might approach this would be appreciated.

 

TrimArray.jpg

Posted

I would draw each segment individually. You only have to write the code once. Thinking that trying to implement the trim command into your code would be more brutal than having your code draw each segment individually. As you said, each position is already made available through variables. It wouldn't be much more to compute the begin and end of each segement and then have your code simply create the lines seperately. I hope that this is at least of some help.

 

regards,

 

Happy Coding!

 

hippe013

Posted
I would draw each segment individually.

 

1+

 

Far easier to calculate the positions of the smaller line segment endpoints than mess around with Trim.

Posted
1+

 

Far easier to calculate the positions of the smaller line segment endpoints than mess around with Trim.

 

Yes, I am finding that out....and Lee, just to show that at least this time, I'm learning from your wonderful and seasoned advice....and not plagerizing...!

 

(setq count 1)
 (repeat (- numribs 1)
   (command "._LINE" (polar (polar pt1 (dtr 90.0) 5.125) (dtr 0.0) 
                             (+ (+ (* riboc count) 1.5) ribthk))
                             (polar (polar pt1 (dtr 90.0) 5.125) (dtr 0.0) 
                             (+ (* riboc (+ count 1)) 1.5)) "")
   (setq count (+ 1 count))
 )

This is how I get the lines to draw in the segments across a distance and quantity of them which both vary depending on what data the code reads from the Excel file. It works with any distance and any number of rectangles.

 

Don't worry, later I will be back in here asking dumb nube questions and plagerizing code by the megabyte..... :D

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