VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp to VBA (Table Data)

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
328 Views, 5 Replies

Lisp to VBA (Table Data)

Need another pointer on converting Vlisp to VBA. Have the following:

(setq XDATA (tblsearch "BLOCK" "Name")
XD (ssget "x" (list (assoc 2 xdata)))
SP (cdr (assoc 410 XD))
)
Which (SP) displays the mode of attachment for an external referenxce file (overlay/ attach).

The VLisp to VBA comparison table has:
AutoCAD.Application.ActiveDocument.collection_object.
Name method

But I cannot find a collection_object when I set a activedocument variable...

Cannot seem to get at the data any other way ethier, any help would be greatly Appreciated.
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

Hmmm, I'm not quite sure what you are doing, but.....this won't work: (cdr
(assoc 410 XD)) because XD is a selection set. You would need to (entget) a
member of the slection set. Second, you say that line displays the mode of
attachment......the 410 code stores the Layout Tab name that the insert is
on.

The comaprison table is referring to collection_object as being the
collection you are interested in. In this case, you probably want to use the
Blocks collection.....AutoCAD.Application.ActiveDocument.Blocks.Item("Name")
will return the collection_object having the Name "Name".


wrote in message news:5423154@discussion.autodesk.com...
Need another pointer on converting Vlisp to VBA. Have the following:

(setq XDATA (tblsearch "BLOCK" "Name")
XD (ssget "x" (list (assoc 2 xdata)))
SP (cdr (assoc 410 XD))
)
Which (SP) displays the mode of attachment for an external referenxce file
(overlay/ attach).

The VLisp to VBA comparison table has:
AutoCAD.Application.ActiveDocument.collection_object.
Name method

But I cannot find a collection_object when I set a activedocument
variable...

Cannot seem to get at the data any other way ethier, any help would be
greatly Appreciated.
Message 3 of 6
Anonymous
in reply to: Anonymous

Yep your quite right (copied in another portion of the VLisp program) the 'real' code in question is:
(setq TST (tblsearch "BLOCK" "Blockname"))
(if TST
(cond
((eq (cdr (assoc 70 TST)) 4) (setq TST "NOT FOUND") )
((eq (cdr (assoc 70 TST)) 😎 (setq TST "UNLOADED ") )
((eq (cdr (assoc 70 TST)) 12)(setq TST "UNLOADED ") )
((eq (cdr (assoc 70 TST)) 36)(setq TST "ATTACHED ") )
((eq (cdr (assoc 70 TST)) 38)(setq TST "ATTACHED ") )
((eq (cdr (assoc 70 TST)) 40)(setq TST "OVERLAYED") )
((eq (cdr (assoc 70 TST)) 44)(setq TST "OVERLAYED") )
)
)

Tried :
Set bdata = AutoCAD.Application.ActiveDocument.Blocks.Item(tempBlock.Name)

But it's just getting me back to where I was before -->
For Each tempBlock In ThisDrawing.Blocks
If tempBlock.IsXRef Then
xrlist(cnt, 0) = UCase(tempBlock.Name) ' xref name
end if
next

And there's no property in the block object which gives me the information I need (attachment type like the 70 group code above).

Thanks though...
Message 4 of 6
Anonymous
in reply to: Anonymous

CADRaven, even though most won't admit it here, when dealing with AutoCAD
objects, Lisp is so much better than VBA. This is but one of the examples.
Try swapping an insert from one block definition to another with VBA: can't
be done. But entmod . . ..

jb
Message 5 of 6
Anonymous
in reply to: Anonymous

Hi James,
While I'll agree there are SOME things that cannot be done (at least not
easily) in VBA, your example falls short. In a test drawing with at least 2
block definitions of "DM" & "DMH", and you wish to change all inserts of the
"DM" to be inserts of "DMH":

Dim oEnt As AcadEntity
Dim oBlk As AcadBlockReference

For Each oEnt In ThisDrawing.ModelSpace
If TypeOf oEnt Is AcadBlockReference Then
Set oBlk = oEnt
If oBlk.Name = "DH" Then
oBlk.Name = "DMH"
End If
End If
Next

This works just fine.

However, you are correct in that VBA, or more correctly ActiveX, does not
allow us to view/change the Xref Status. This is something we've been asking
for for years.

Jeff


"James Buzbee" wrote in message
news:5423338@discussion.autodesk.com...
CADRaven, even though most won't admit it here, when dealing with AutoCAD
objects, Lisp is so much better than VBA. This is but one of the examples.
Try swapping an insert from one block definition to another with VBA: can't
be done. But entmod . . ..

jb
Message 6 of 6
Anonymous
in reply to: Anonymous

OK Then... Good to Know and yeah there's a lot of stuff I could do much more easily with VLisp, mostly entity access and modification stuff oh and yeah selection filters too no that I think about it...

Your telling me that there's just no-way to access object association codes with VBA?

Well that puts a new perspective on things and thanks for you input, when the going get's tough the tough write a hack hack...

Private Sub makexlist() ' Fill in the xref listbox
Dim tempBlock As AcadBlock, ASSOC70 As Integer
ReDim xrlist(ThisDrawing.Blocks.Count, 3) ' Redimension global array (defined in Module 1)
cnt = 0 ' Global xref counter (ditto)
For Each tempBlock In ThisDrawing.Blocks
If tempBlock.IsXRef Then ' Set bdata = AutoCAD.Application.ActiveDocument.Blocks.Item(tempBlock.Name)
xrlist(cnt, 0) = UCase(tempBlock.Name) ' add the xref name to the array
xrlist(cnt, 1) = UCase(tempBlock.Path) ' add the xref path name
' **Hack **Hack **Hack **Hack **Hack **Hack **Hack **Hack **Hack **Hack **Hack
ThisDrawing.SetVariable "USERI1", 0 ' ThisDrawing.SetVariable("USERI1", 0)
' (SETVAR "USERI1" (cdr (assoc 70 (tblsearch "BLOCK" "Blockname"))))
ThisDrawing.SendCommand ("(SETVAR " & Chr(34) & "USERI1" & Chr(34) & Chr(32) & "(cdr (assoc 70 (tblsearch " _
& Chr(34) & "BLOCK" & Chr(34) & Chr(32) & Chr(34) & tempBlock.Name & Chr(34) & "))))" & vbCrLf)
ASSOC70 = ThisDrawing.GetVariable("USERI1")
xrlist(cnt, 2) = ASSOC70 ' tempBlock.Handle ' status (type overlay/ attached --> (cdr assoc 70)
cnt = cnt + 1
End If
Next
End Sub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost