user selects a block and a vport.
program writes a field in the attribute that will display the vport scale.
any help or sample code is appreciated.
thanks
You can try the attached code, the sample applies the field to a text object that gets placed at the center of the viewport.
You can just apply the value to your block attribute instead, but I have not tested it that way. It can get you started, shows how to select a viewport, you can use the same method to select your block.
The sample is in C#.
Thanks for your help, this is great stuff.
It seems you simpley write the field text string with the object id.
once again thanks
I am also now looking to add an expresion into the field, I did it manually i.e. 1 / vport custom scale.
so this is what the string looks line with no expression
%<\AcObjProp Object(%<\_ObjId 8796088114864>%).CustomScale \f "%lu2%qf2816">%
with the expression
%<\AcExpr (1/%<\_FldPtr 760454032>%) \f "%lu2">%
so if I have
ID="8796088114864"
S1 = "%<\AcObjProp Object(%<\_ObjId" & ID & ">%).CustomScale \f "%lu2%qf2816">%"
S2 = "%<\AcExpr (1/%<\_FldPtr" & S1 & ">%) \f "%lu2">%"
does this work ???? I am thinking maybe not
HELP ug!!!!!!
Thanks, but that did not work in VB.
yes I am still having problems, I have got it to a point to do the calculations, however, it inserts the resulant value rather than the fielkd.
to create the field strind
Dim myField1 As New DatabaseServices.Field(" %<\AcExpr (1/%<\AcObjProp.16.2 Object(" + myVportID.OldIdPtr.ToString + ").CustomScale \f ""%lu2%qf2816"">%) \f ""%lu2"">%") myField1.Evaluate()
then to insert the field into the attribute I use
myAttRef = myEnt.GetObject(OpenMode.ForWrite) myAttRef.SetField(myfield1)
but instead of a field in the attribute, I get a value.
any idea, is there a simpler method
You can try using portions of the attatched command code.
Select a viewport, select a block, sets all 'setable' attributes within the block to the field.
The code is not commented but self explanitory...
Also attached a dwg (2010) containing a simple block with single attribute on a layout to test the command.
Nothing short of brilliant
Thanks, so, very much.
I guickly ran the program and it worked greate, now I need to step through it and understand every thing you did.
Seems you know your stuff.
Once again thanks.
another quick question I see for format
Format1 i.e Format: #:1 you have the code "%lu2%qf2816:1"
however when I manually create a field in AutoCad in the evaluate field expresion I get "%lu6%ps[,:1]"
I thought I could simpley go to AutoCad to generate the syntax, then copy it and paste it into my program, it did not work
Obviously the syntax you have is correct and works, where did you get this info?
what I need is for a format that is current units with zero suppression of trailing and leading
thanks in advance.
your code that works
ViewportScaleFieldFormatString =String.Format("%<\AcObjProp Object(%<\_ObjId {0}>%).CustomScale \f ""%lu2%qf2816:1"">%", vpIdVal)
and this one does not
ViewportScaleFieldFormatString =String.Format("%<\AcObjProp Object(%<\_ObjId {0}>%).CustomScale \f ""%lu2%ps[,:1]"">%", vpIdVal)
I copied from the field expression box and pasted into my code file. The Custom scale property of the Viewport object doesn't give any additional formatting options so you won't be able to apply the current units and zero suppression there.
You can specify additional formatting in the formula evaluation portion: