Place Block with dimscale

Place Block with dimscale

CS93X7Q
Contributor Contributor
454 Views
5 Replies
Message 1 of 6

Place Block with dimscale

CS93X7Q
Contributor
Contributor

 

Hello all

I am looking for some guidance. I have this lsp that I made. It does work. What I want to do is place a block in either model or layout. If it is placed in model space I want to use the dimscale as the block scale, and if it is placed in layout, I want to use 1 as the block scale. I know annotation scale will take care of this but I want to do this without using annotation scale. It works fine in model, but in layout it will first place the block at 1, but then right away, because I have the command in a second time, it will want to place the block a second time at the dimscale when in layout. Is there a way to clean this up or a better way to do this? The block is not annotative.

 

(defun C:TestPlaceElevationMark ()
(if(=(getvar "CTAB") "Model")
(setq xscalestr (getvar "dimscale"))
(command "insert" "C:/Data/_Library/Blocks/Common/Annotation/Dyn_Elevation.dwg" pause 1 0)
);end if
(command "insert" "C:/Data/_Library/Blocks/Common/Annotation/Dyn_Elevation.dwg" pause xscalestr 0)
)

0 Likes
Accepted solutions (1)
455 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

It looks like you want the second Insertion to happen only if in Paper Space, but the way you have it set up, outside the (if) function, it happens every time, regardless of what happened or didn't in that (if) function.  You can put the (if) part inside the Insert command, since it affects only the scale factor, and save yourself some code duplication [and an unnecessary variable].  Try something like this [untested]:

 

(defun C:TestPlaceElevationMark ()
  (command "insert"

    "C:/Data/_Library/Blocks/Common/Annotation/Dyn_Elevation"

    pause ; insertion point

    (if (= (getvar "CTAB") "Model") (getvar "dimscale") 1); scale

    0 ; rotation

  ); command
)

 

Or better yet, so that you can see it at scale as you drag it into place in either space, use the Scale option before supplying the insertion point:

 

(defun C:TestPlaceElevationMark ()
  (command "insert"

    "C:/Data/_Library/Blocks/Common/Annotation/Dyn_Elevation"

    "_scale" (if (= (getvar "CTAB") "Model") (getvar "dimscale") 1)

    pause ; insertion point

    0 ; rotation

  ); command
)

 

[Also, a small thing -- you don't need to include the .dwg filetype ending.  It won't consider any other kind.]

Kent Cooper, AIA
0 Likes
Message 3 of 6

CS93X7Q
Contributor
Contributor

Thanks Kent

This worked perfectly. I like the second one where it can be seen at scale.

0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant

You're welcome.  Another advantage of the second one is that it doesn't matter whether or not a Block is defined for uniform scaling.  The first one contains only one scale factor input, so if used with a Block not defined for uniform scaling, it would be missing an input.  But the Scale option applies the value to the scales in all directions at once, so it doesn't matter how many scale prompts there would be if after the insertion point.

Kent Cooper, AIA
0 Likes
Message 5 of 6

CS93X7Q
Contributor
Contributor

Do you know if there is there a way to apply the dimscale to text height and multileader scale?

0 Likes
Message 6 of 6

Kent1Cooper
Consultant
Consultant

@CS93X7Q wrote:

Do you know if there is there a way to apply the dimscale to text height and multileader scale?


Investigate Annotative Text Styles.  But short of that, say you want to define a Text Style with a fixed height of 2.5mm as plotted, but for use in model space, where the "real" height required would depend on the DIMSCALE value.   In a STYLE command, where it asks for the height, give it:

 

(* (getvar 'dimscale) 2.5)

Kent Cooper, AIA
0 Likes