3dwannab Posted December 8, 2022 Posted December 8, 2022 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. Block Replace but Retain Overall Size.dwg Quote
mhupp Posted December 8, 2022 Posted December 8, 2022 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) Quote
ronjonp Posted December 8, 2022 Posted December 8, 2022 (edited) @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 December 8, 2022 by ronjonp 1 Quote
BIGAL Posted December 9, 2022 Posted December 9, 2022 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. Quote
3dwannab Posted December 9, 2022 Author Posted December 9, 2022 (edited) 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 December 9, 2022 by 3dwannab 1 Quote
Steven P Posted December 9, 2022 Posted December 9, 2022 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 1 Quote
mhupp Posted December 9, 2022 Posted December 9, 2022 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. 1 Quote
Steven P Posted December 9, 2022 Posted December 9, 2022 (edited) 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 December 9, 2022 by Steven P Quote
mhupp Posted December 9, 2022 Posted December 9, 2022 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!!@#@!#?" 1 Quote
BIGAL Posted December 9, 2022 Posted December 9, 2022 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. Quote
Recommended Posts
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.