I am trying to produce a simple vba routine to get a pline, and provide the area via a field code. I have yet to find anything that explains field codes for vba. Are they exposed?
I am trying to produce a simple vba routine to get a pline, and provide the area via a field code. I have yet to find anything that explains field codes for vba. Are they exposed?
Hi sdp777,
We're going to need a bit more information here - as a general rule, more information is better than less.
What application? Version? Can you post a small, sanitised sample of what you're trying to achieve?
Valid points...I get onto to people who do that to me.
Autocad and VBA.
I was able to find out some information as to how to do via a friend, prolly one of the sharpest code guys still on the free market, relative to CAD, programming languages. For all.
[VBA]
Sub CreateField()
Dim vPt As Variant, vObj As Object, vObjPt As Variant
ThisDrawing.Utility.GetEntity vObj, vObjPt, vbLf + "Select polyline: "
vPt = ThisDrawing.Utility.GetPoint(, vbLf + "Pick point for mtext: ")
Dim strfield As String
strfield = "%<\AcObjProp Object(%<\_ObjId " + CStr(vObj.ObjectID) + ">%).Area>%"
Dim acMtext As AcadMText
ThisDrawing.ModelSpace.AddMText vPt, 2, strfield
End Sub
[/VBA]
Sincerely,
Steven D. Papke
President and Owner
Visit the vizdepot!
This isn't going to work. The 2 needs to be calculated. It is supposed to be the width of the "box" surrounding the mtext entity. I use Len(string) * textheight * widthfacteroftextstyle. It is not completly correct but it is close enough for what I am doing (I use a lot of big fonts).ThisDrawing.ModelSpace.AddMText vPt, 2, strfield
strfield looks like a call to lsp from vba(I hope) is it?
It works because MTEXT ignores the width value if the field is one word. In this case, its a field code for a number. You idea tho definitely has a value though. strfield, I believe is vlisp.
There is a file called Vlax.cls that makes the communication with lisp easier, I haven't used it.
What are you calling a field code? I am not familiar with that. dcl, lsp, vba, scr
I have Acad 2000i.