TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: mjfarrell on August 13, 2007, 07:04:18 PM
-
I'm trying with not much success here....
I want to fill in the scale, and increments of that scale on a graphic scale bar using Fields.
Anyone tried to do this with any success..($(getvar, vpscale)*4) or other?
-
this is the field code you want to use <i took the code out of the field dialog box and modifed it a little bit. It is from the custom scale 1:scale setting except I removed 1:>
%<\AcObjProp Object(%<\_ObjId 2126456848>%).CustomScale \f "%lu2%ct1%qf2816">%
then use something similar to the code below to extract and change the object id.
(setq ent (entsel "select viewport:"))
)
(if ent
(progn
(setq ent (vlax-ename->vla-object (car ent)))
(objmtxt)
)
)
(princ)
)
(defun objmtxt ()
(setq objidlwpoly (vla-get-objectid ent))
(setq lwpolyobj (itoa objidlwpoly))
(setq atfield
(strcat
"%<\\AcObjProp Object(%<\\_ObjId "
lwpolyobj
">%).CustomScale \f "%lu2%ct1%qf2816">%
)
)
then use your variable in your scale bar (please note that this will only get you the actual scale of the viewport and not any of the other increments on your scale bar. you'll have to play with the diesel code to see if thats possible)
-
CT,
Thanks for the response, I could already get the viewport scale with either a field or deisel expression.
It's the other values that I'm most interested in having it fill in for me.
-
I tried this when fields first came out. I really wanted an area by polyline command. But I found out quickly that the options with fields are limited. So I wouldn't waste too much time.....
If I figure out something, I will be more than happy to share it with you. Good luck!
-
I created a block of my scale bar with attributes for the values. The tags of the attributes are 0.5, 1.0, 2.0 etc, corresponding to the values displayed on the final, scaled bar. Then my code cycles through the attributes, multiplying the tag value by the scale factor.
This code is used to populate the attributes in the block reference.
(defun dkb_insScaleBlock(pBLockName pCurrSpaceObj pInsPoint pInsertScale pScaleFactor / COUNT
OATTRIB OSCALEBAR SAATTRIB SAMAX VATTRIB)
(setq oScaleBar (vla-insertblock pCurrSpaceObj pInsPoint pBlockname pInsertScale pInsertScale pInsertScale 0.0 )
vAttrib (vla-getattributes oScaleBar)
saAttrib (vlax-variant-value vAttrib)
saMax (+ 1 (vlax-safearray-get-u-bound saAttrib 1))
Count 0
)
;; **** cycle thru the attributes and multiply the tag-string by the desired scale factor *****
(repeat saMax
(setq oAttrib (vlax-safearray-get-element saAttrib Count))
(vla-put-textstring oAttrib (rtos (* pScaleFactor (atof (vla-get-tagstring oAttrib))) 2 0))
(vlax-release-object oAttrib)
(setq Count (+ 1 Count))
);end repeat
(vlax-release-object oScaleBar)
);defun css_insScaleBlock
It doesn't use Diesel, but maybe it will give you some ideas