Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Block duplication - Within limits

25 REPLIES 25
SOLVED
Reply
Message 1 of 26
k005
1044 Views, 25 Replies

Block duplication - Within limits

Hello friends;


How can I reproduce the block as I have given in the drawing in the example?

 

 

X distance 45.6

Y distance 45.6

 

In this example, the number of duplicated blocks is 456.

 

* that is, it can exceed the limit by a maximum of 45.6/2. or 45.6/2 in the space within the border.

 

Thanks in advance to the helpful friend.

 

25 REPLIES 25
Message 2 of 26
-didier-
in reply to: k005

Bonjour @k005 

 

it would be a good idea to help us understand to provide us with a DWG with acceptable solutions.

Should we provide a solution in LSP or AutoCad native commands?

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

Didier Aveline

EESignature

Message 3 of 26
k005
in reply to: -didier-

So, it would be much more useful if we could do it with LSP. In fact, in the logic of the array command...

Message 4 of 26
Kent1Cooper
in reply to: k005


@k005 wrote:

So, it would be much more useful if we could do it with LSP. In fact, in the logic of the array command...


More useful than what?  Why not with an ARRAY command itself?

 

A drawing or image showing something like the result you want, with description(s), would clarify what we're not understanding.  Is the attached the right idea, to get as many in as will fit at the desired spacing, with a bordering space at a limited size between the Blocks and the perimeter?

 

I did that very quickly with an associative Array command and grip-stretching visually for the columns and rows [no calculation needed], and a simple MOVE command to put the M2P point in the middle of the Array at the M2P point in the middle of the border.  It was almost as quick as any AutoLisp routine could make it.  But maybe I didn't understand what you want correctly.

Kent Cooper, AIA
Message 5 of 26
k005
in reply to: Kent1Cooper

Sorry, I'm attaching a file showing the result right away...

************************************************

 

My goal: Using the fields, make a calculation and place the blocks.


As follows, first select the boundary polyline and then select the block to be placed. and make calculations.

 

 

There is a situation here. There needs to be 0.3cm space for this placement. in every direction. This automatically means 0.6cm. and this is constant. The only thing that changes is the block size. It could be in a block like 50x50. In other words, my aim is to make a settlement without crossing the border, or just barely crossing it.

 

 

Message 6 of 26
-didier-
in reply to: k005

Bonjour @k005 

 

I don’t understand the details, it’s only in your head and I have no way of knowing.
What is the overflow value for choosing to create a blank or create an overlap at the end of the line.

I would like to help you, but I have to understand before I do it.

Other questions : 
other blocks exist? Do they always have the same values x and y? And how are they named?

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

Didier Aveline

EESignature

Message 7 of 26
Kent1Cooper
in reply to: k005


@k005 wrote:

.... There needs to be 0.3cm space for this placement. in every direction. This automatically means 0.6cm. ....


No, it means 0.3cm between Blocks, and in your 45x45 Block, 45.3 from one Block insertion point to the next, contradicting your original description [Measure them in your own drawing].

As @-didier- asked, are the Blocks always square, and what is the limit on what constitutes "barely crossing" the border?  Is your " * that is " sentence in Message 1 about this?  Does it mean half a Block spacing is the most it can cross the border, and also the most it can fall short of the border?  [Half a Block spacing seems like a lot more than "barely" crossing it, to me.]

 

If the Blocks may not be square but are always rectangular, and if their names are always their size, which part of the name is the horizontal dimension and which the vertical?

 

Is the border always rectangular?

Kent Cooper, AIA
Message 8 of 26
k005
in reply to: Kent1Cooper

The border is most often rectangular. or sometimes it can be square. Or let's say triangle. circle... that is, whatever the shape. is a polyline. And that is the limit.

 

By X and Y I mean: 45.6x45.6.

Message 9 of 26
k005
in reply to: -didier-

There is no naming. I gave X and Y only as sample distances. My goal is to copy this square block into the area drawn in red at a distance of 45.6 units in X and 45.6 units in Y.

 

LSP OPERATION ORDER

-------------------------


1- Select the limit

2- select the block


Result: 456 blocks have been copied. (This is for the border in the dwg I gave...)

 

Message 10 of 26
Kent1Cooper
in reply to: k005


@k005 wrote:

The border is most often rectangular. or sometimes it can be square. Or let's say triangle. circle....


That spoils the associative Array approach I used before as part of a general solution....

 

And I can imagine how to place a first Block if the border is rectangular, but what would be the placement if it's a Circle, or a triangle?  Should they still be in rows and columns to fill shapes like those?

 

Would SUPERHATCH be a way to do what you want, or at least to give you an initial distribution of Blocks, from which you can remove those that violate the border?

Kent Cooper, AIA
Message 11 of 26
k005
in reply to: Kent1Cooper

Circle or triangle is not always. Mostly Rectangular. What I want to do is for the code that fills the Rectangle to work on other shapes as well. Of course, this may not give as accurate results as the Rectangle.

Message 12 of 26
Sea-Haven
in reply to: k005

This is like similar place blocks on shapes another today was circles on any pline shape, ok start with block 1x1 in size so use scale for size if not fixed at 45, your sample dwg is a block 45x45 with 0.3 gap, so just need a control point that you would start at, for a rectang is easy its top left in sample dwg, for a circle and I do mean a circle say left quadrant. You can work out a bounding box of pline so work out the array parameters, for the circle easiest way is over make array and delete those outside the circle. Again looking at dwg the right side should be trimmed back to 0.3 and the block closed to look right. 

 

A random shape and something I worked on I solved the problem but was based on a start point so array pattern could be made. 

 

I think we need a lot more sample shapes before committing to an answer. Again need after to see where control point is. 

SeaHaven_1-1704618277287.png

 

 

Message 13 of 26
-didier-
in reply to: k005

Bonjour

 

unfortunately I cannot help in this case, my English is not good enough to follow your discussions, it seems that I do not always use the right words for my question (hihi).

If the statement were clear and unequivocal I would have started to work, but now I can not follow.

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

Didier Aveline

EESignature

Message 14 of 26
k005
in reply to: Sea-Haven

Yes, this way. Super. This is exactly what I want.


The rest outside the circle will be used as waste for me. So it works for us outside the apartment... (unless we exceed the limit with too much gas, of course..)


This can happen not only in circles but also in rectangles. and it is the acceptable value... custom.

Message 15 of 26
k005
in reply to: -didier-

no problem. Thanks.

Message 16 of 26
Kent1Cooper
in reply to: k005

I repeat my suggestion that you look into SUPERHATCH, which will do these kinds of things:

Kent1Cooper_0-1704631500212.png

The cropped Blocks around the perimeters are full Blocks, masked off, so if you want to see the "waste" part, you can Explode individual Blocks.

Kent Cooper, AIA
Message 17 of 26
k005
in reply to: Kent1Cooper

I can use them as waste in case of overflowing the borders. In your example these appear to be truncated. In this case, the number will be incomplete. Too much is acceptable to some extent. It is unacceptable that it is missing.

Message 18 of 26
Sea-Haven
in reply to: k005

I think superhatch is the way to go, make a hatch pattern, Bricscad has a waffle pattern.

 

Ok question can we move the hatch so say a bottom left cnr aligns with a pick point ? You can move the pattern origin . On a rectang could be worked out but on a random shape appears to be difficult. Will look into it more.

 

 

*WAFFLE,WAFFLE
0, 0.35,0.25, 0,0.6, 0.5,-0.1
0, 0.35,0.35, 0,0.6, 0.5,-0.1
90, 0.25,0.35, 0,0.6, 0.5,-0.1
90, 0.35,0.35, 0,0.6, 0.5,-0.1

 

 Desirable

SeaHaven_0-1704674832369.png

Just a comment the hatch will show as "U" & "L" etc there is a way to add back in the missing side so dwg looks correct, but need to figure out hatch origin 1st. Ps thanks to CAB for missing line solution.

Message 19 of 26
k005
in reply to: Sea-Haven

In my opinion, the solution is not with a hatch pattern, but with a copying method that partially exceeds the borders.

 
 

 

 

Message 20 of 26
Sea-Haven
in reply to: k005

Try this it does use a hatch so no trimming required. It does require a control point so lower left corner of 45x45 starts there. Very limited testing, hatch pattern included.

 

 

; hatch to a bounraty and align
; By AlanH Jan 2024

(defun c:wow ( / pt ss obj cpt pt)
(setq pt (getpoint "\npick control point on pline "))
(setq ss (ssget pt '((0 . "LWPOLYLINE,CIRCLE"))))
(if (= ss nil)
(alert "pline not found")
(progn
(setq obj (vlax-ename->vla-object (ssname ss 0)))
(if (= (vla-get-objectname obj) "AcDbCircle")
(setq cpt (vlax-get obj 'Center))
(setq cpt (osnap (vlax-curve-getStartPoint obj) "gcen"))
)
(command "hatch" "P" "Waffle2" 1 0.0 cpt "")
(setq obj (vlax-ename->vla-object (entlast)))
(setq pt (mapcar '+ pt (list -0.3 -0.3 0.0)))
(vlax-put obj 'origin pt)
)
)
(princ)
)
(c:wow)

 

You must preload this hatch pattern.

 

*WAFFLE2,WAFFLE2
0, 0.3,0.0, 0,45.3, 45.0,-0.3
0, 0.3,0.3, 0,45.3, 45.0,-0.3
90, 0.0,0.3, 0,45.3, 45.0,-0.3
90, 0.3,0.3, 0,45.3, 45.0,-0.3

 

 

Limited Testing on plines and circles.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report