Consulting

Results 1 to 6 of 6

Thread: VBA with Fields

  1. #1
    VBAX Regular
    Joined
    Feb 2007
    Posts
    6
    Location

    VBA with Fields

    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?

  2. #2
    VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    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?

  3. #3
    VBAX Regular
    Joined
    Feb 2007
    Posts
    6
    Location
    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!

  4. #4
    VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,168
    Location
    ThisDrawing.ModelSpace.AddMText vPt, 2, strfield
    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).

    strfield looks like a call to lsp from vba(I hope) is it?

  5. #5
    VBAX Regular
    Joined
    Feb 2007
    Posts
    6
    Location
    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.

  6. #6
    VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,168
    Location
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •