Jump to content

settin data to cad table via VBA


mine

Recommended Posts

Hi

I can't find the way how to insert data from vba script to existig table in acad 2008.

I'm looking for some advise :)

 

przemek

Link to comment
Share on other sites

Maybe i'll write some more about my problem...:)

I'm a civil enginer and i use tables in autocad and i wonder haw to use logic functions like "if" in cells (like in excel) and only way, I found out, is to calculate sth in vba using logic functions and to put this integer to cell in existing table in modelspace , but I can,t menage to write it.

please help:oops:

Link to comment
Share on other sites

I’m not exactly sure the full extent of what you need but the response I made in this thread was based on the code below. A table was already preset with the header information and I did modify the code a bit when processing the right side of the parabola.

 

Nonetheless, it does give an example of VBA coding some Table modifications.

 

http://www.cadtutor.net/forum/showthread.php?t=38670

 

 

Option Explicit

Sub PutPtCoors2Table()
Dim entTable As AcadTable
Dim entArc As AcadArc
Dim i As Integer, j As Integer
Dim intCount As Integer
Dim intCode(0) As Integer
Dim varData(0) As Variant
Dim colSS As AcadSelectionSet
Dim ent As AcadEntity
Dim varpt As Variant
Dim varCen As Variant, varSt As Variant, varNd As Variant

With ThisDrawing

  intCode(0) = 0: varData(0) = "Arc"
  intCount = SoSSS(intCode, varData) - 1
  If intCount > 0 Then
     .Utility.GetEntity ent, varpt, "Select a Table: "
     If TypeOf ent Is AcadTable Then
        Set entTable = ent
     Else
        Exit Sub
     End If
     
     Set colSS = .SelectionSets.Item("TempSSet")
     For i = 0 To intCount
        Set entArc = colSS(i)
        varCen = entArc.Center
        varSt = entArc.StartPoint
        varNd = entArc.EndPoint
  
        For j = 0 To 2
        entTable.SetText i + 4, 1 + j, CStr(Round(varCen(j), 5))
        entTable.SetText i + 4, 4 + j, CStr(Round(varSt(j), 5))
        entTable.SetText i + 4, 7 + j, CStr(Round(varNd(j), 5))
        Next
     Next
  
  End If
End With
End Sub

Link to comment
Share on other sites

Oops, just realized that I didn’t include all the supporting functions. :cry:

 

Include this with the code from my previous message.

 

Sub SSClear()
Dim SSS As AcadSelectionSets
  On Error Resume Next
  Set SSS = ThisDrawing.SelectionSets
     If SSS.count > 0 Then
        SSS.Item("TempSSet").Delete
     End If
End Sub

Function SoSSS(Optional grpCode As Variant, Optional dataVal As Variant) As Integer
  Dim TempObjSS As AcadSelectionSet
  SSClear
  Set TempObjSS = ThisDrawing.SelectionSets.Add("TempSSet")
        'pick selection set
  If IsMissing(grpCode) Then
     TempObjSS.SelectOnScreen
  Else
     TempObjSS.SelectOnScreen grpCode, dataVal
  End If
  SoSSS = TempObjSS.count
End Function

Link to comment
Share on other sites

Thanks a lot for help and that you took this trouble, I've just started to think out this function...:), but it seems to work in my drawing

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...