Message 1 of 12
Use Formula and object area in VBA.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I've made a little VBA script which let me select a polyline and it gives me a MText block with the area of the polyline attached. This was with a precision of 1 decimal.
See the code:
Set NewText = ThisDrawing.ModelSpace.AddMText(RetPoint, 0, "%<\AcObjProp.16.2 Object(%<\_ObjId " & returnObj.ObjectID & ">%).Area \f " & "%lu2%pr1%ds44%ct8[1.0E-006]%th46" & ">%" & " m²")
I'd like to round the area to 5 m².
On different forums I've read we can use te Round((xx/5)*5). This works if I do it in Autocad itself.
%<\AcExpr (round(%<\_FldPtr 1846094436224>%/(5*10^6))*5) \f "%ps[, m²]">%
I think 1846... is the ObjectID from the selected Polyline.
But if I will use this as a string in VBA the field gives ### when I give this statement:
RetVal = "%<AcExpr (round((%<\_FldPtr " & returnObj.ObjectID & ">%/(5*10^6)*5)>%"
Does anyone know if it is possible to do in VBA?
Thanks in advance.
Greetz Bjørn