Author Topic: Use Diesel Expression to set Scale Values  (Read 2085 times)

0 Members and 1 Guest are viewing this topic.

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Use Diesel Expression to set Scale Values
« 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?
Be your Best


Michael Farrell
http://primeservicesglobal.com/

CTMill

  • Newt
  • Posts: 120
Re: Use Diesel Expression to set Scale Values
« Reply #1 on: August 15, 2007, 01:51:45 PM »
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)
« Last Edit: August 15, 2007, 01:53:58 PM by CTMill »
Civ3d/A2K16

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Use Diesel Expression to set Scale Values
« Reply #2 on: August 15, 2007, 01:56:54 PM »
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.
Be your Best


Michael Farrell
http://primeservicesglobal.com/

CTMill

  • Newt
  • Posts: 120
Re: Use Diesel Expression to set Scale Values
« Reply #3 on: August 15, 2007, 02:31:18 PM »
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!
Civ3d/A2K16

SomeCallMeDave

  • Guest
Re: Use Diesel Expression to set Scale Values
« Reply #4 on: August 17, 2007, 09:44:11 PM »
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.

Code: [Select]
(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