PDA

View Full Version : Scaling blocks inserted with DIVIDE


l3ch
2009-03-25, 07:04 PM
I want to insert along lines, arcs or plines - call them axis from now-, some blocks (symbols representative of what is the axis), aligned with the axis.

For me, the easiest way is using "DIVIDE".

The problem is, the user should fix the scale of the block.

If I try something like that:
(vl-cmdf "_DIVIDE" ent_axis "_block" blockname "_y" (1+ n_blocks_desired))
then I cannot introduce the scale of the block.

How could I do it?

T.Willey
2009-03-25, 08:50 PM
Within a lisp use the divide command. Pseudo code

Use ' entlast ' to get the last entity add to the drawing.
Use the divide command
Use ' entnext ' on the entity gotten with step 1, to step through all the new entities added to the drawing. Make sure you only change those that are blocks, as ' entnext ' used on a block that has attributes will grab the attributes associated with said block before it will grab the next block insert.

Hope that helps.

l3ch
2009-03-25, 09:04 PM
Hey! What a trick! I'm sure it will work.

I'll write the code and upload here, to see how it appears.

Thanks, T.

aaronic_abacus
2009-03-26, 02:54 AM
You could also use (ssget "p") after the divide command for a selection set of blocks.

l3ch
2009-03-26, 10:42 AM
This is the last code. It works very good for me.

(defun ScaleDivide (blockName blockScale chip / axis axis_layer axis_linescale nblock ent_first ent_block)
(if chip (setq textcommand "_DIVIDE") (setq textcommand "_MEASURE")) ;;; 2 by the price of 1
;;; It's supossed block is created with color and ltype ByBlock, so user can set desired properties.
;;; Block is inserted in axis'layer
(while (setq axis (car (entsel "Select entity: ")))
(setq ent_first (entlast))
(setq axis_layer (cdr (assoc 8 (entget axis))))
(setq axis_linescale (cdr (assoc 48 (entget axis))))
(initget 7)
(if chip ;;; If T the command will be DIVIDE, nil will be MEASURE
(setq n_block (1+ (getint "How many simbols? ")))
(setq n_block (getint "Distance between symbols: "))
)
(vl-cmdf textcommand axis "_block" blockName "_y" n_block)
(setq ent_block ent_first)
(while (setq ent_block (entnext ent_block))
(change_entity ent_block 8 axis_layer) ;;; So block is in axis layer
(change_entity ent_block 48 axis_linescale) ;;; So block has axis' line type scale
;;; At last: The scale of the block.
(change_entity ent_block 41 blockScale) ;;; X scale
(change_entity ent_block 42 blockScale) ;;; Y scale
(change_entity ent_block 43 blockScale) ;;; Z scale
) ;;; End of changing blocks
) ;;; End of dividing elements
) ;;; End of function

;;; Note: change_entity is my own function for that, I supposse everybody has one.

T.Willey
2009-03-26, 04:56 PM
Glad it worked for you. You're welcome.