Jump to content

Replace blocks but keep their overall size


3dwannab

Recommended Posts

I've searched for a routine to do this below but no luck. There's no point in reinventing the wheel, so if anyone know of one that would be great.

 

I see the program working is that it gets the extents of the item and scales the block accordingly. It's probably a very complex program.

 

Attached is a sample drawing.

 

image.thumb.png.d83d8a6fe9a6fd29620738ae74f3abd0.png

Block Replace but Retain Overall Size.dwg

Link to comment
Share on other sites

1. if those old trees are the same block but different scales

insert block with scale

;   XScaleFactor = 2.0
;   YScaleFactor = 2.0
(vl-cmdf "-Insert" "Blockname" PT 2 2 0)
(vl-cmdf "-Insert" "Blockname" PT (vlax-get oldblk 'XScaleFactor) (vlax-get oldblk 'YScaleFactor) 0)

 

2. if they are the same relative shape, but different sizes use bounding box to get their over all dims

divide new block size by old size to get the scale

insert block with said scale

(vla-GetBoundingBox Newblk 'LL 'UR)
(setq LL (vlax-safearray->list LL)
      UR (vlax-safearray->list UR)
      L&W (mapcar '- UR LL)  ;subtracked UR from LL to get overall lenght and width of block
      NL (car L&W)
      NW (cadr L&W)
)
(vla-GetBoundingBox Oldblk 'LL 'UR)
(setq LL (vlax-safearray->list LL)
      UR (vlax-safearray->list UR)
      L&W (mapcar '- UR LL)
      OL (car L&W)
      OW (cadr L&W)
)
(setq SclX (/ NL OL))
(setq SclY (/ NW OW))
(vl-cmdf "-Insert" "Blockname" PT SclX SclY 0) 

 

Link to comment
Share on other sites

@3dwannab

FWIW .. instead of making a new block for different sizes that have the same geometry create one definition that is 1unit * 1unit and set it to scale uniformly then you can set the size based on the actual canopy area. If it was structured like this, then all you have to do is grab the X value and set that the same on your new block. Just some organizational insight.

Block Replace but Retain Overall Size - RJP.dwg

Edited by ronjonp
  • Like 1
Link to comment
Share on other sites

Trees can have 2 objects that are measured, the trunk size and the spread. TR6-3 for us is a 6m dia tree with a 300mm trunk, so next part was use a dynamic block with a circle for trunk and a spread pattern. Looking at point coding correct tree shape is created. 

 

So like ronjonp can set the spread of a dynamic block. 

 

Next answer if same block but different scales why not bedit and attsync all done.

Link to comment
Share on other sites

The trees have came in from an external survey company and was just trying to hatch the canopy of the tree. So instead of hatching each individual tree I was looking to create one block with the hatched canopy and replace all the other blocks which are inherently different.

 

I do have a tree block that's dynamic which scales to the canopy size, but for this job I just used the existing block.

 

I think @mhupp may have what I was looking. 

Edited by 3dwannab
  • Like 1
Link to comment
Share on other sites

2 hours ago, 3dwannab said:

The trees have came in from an external survey company and was just trying to hatch the canopy of the tree. So instead of hatching each individual tree I was looking to create one block with the hatched canopy and replace all the other blocks which are inherently different.

 

1000 identical trees each saved as a unique block definition (with possibly the only difference being the base point)? Got to love a contractor who supplies drawings like that

  • Like 1
Link to comment
Share on other sites

1 hour ago, Steven P said:

 

1000 identical trees each saved as a unique block definition (with possibly the only difference being the base point)? Got to love a contractor who supplies drawings like that

 

Not saying its what they are doing but sometimes contractors want to do the work in house, but are told to send what they have to a third party. so they make it as difficult as possible to work on the drawings.

 

I once had a drawing sent to me that had over 200 nested levels for every block (over 1000) for no reason.

  • Like 1
Link to comment
Share on other sites

30 minutes ago, mhupp said:

 

Not saying its what they are doing but sometimes contractors want to do the work in house, but are told to send what they have to a third party. so they make it as difficult as possible to work on the drawings.

 

I once had a drawing sent to me that had over 200 nested levels for every block (over 1000) for no reason.

 

Costs them time and money to do that, but suspect that is what a lot do. One day - when I get a week to work on it - I want a block replacer LISP to replace similar blocks with a single block - which would have answered this question perfectly.

 

Should have been a matter of moments make up a LISP to un-nest the blocks if needed (never had that one yet)

 

 

 

 

 

(should have a thread 'how to screw up a drawing' with all these tips and tricks)

Edited by Steven P
Link to comment
Share on other sites

I think they had like splines half way thought that were hidden or frozen making the drawing super huge like 400mb.

I found a lisp that kept the top level block but burst all nested levels once that was done and splines deleted and purged the drawing was like 2mb

(think it was lee mac's)

 

25 minutes ago, Steven P said:

 

One day - when I get a week to work on it - I want a block replacer LISP to replace similar blocks with a single block - which would have answered this question perfectly.

 

31 minutes ago, Steven P said:

(should have a thread 'how to screw up a drawing' with all these tips and tricks)

Set drawing limits in the middle of no where (or really small)

(setvar 'LIMCHECK 1)

 

"Why can't i create anything the layer isn't locked!!@#@!#?"

  • Like 1
Link to comment
Share on other sites

So the blocks are 1 name if so use bedit and attsync, or are you saying each block has a individual name ?

 

Bricscad has a make block from common objects Blockify, so would explode all trees and it would then remake into a reduced number of blocks. 

 

 

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