Author Topic: VBA from 2k to 2k4  (Read 4270 times)

0 Members and 1 Guest are viewing this topic.

Jeff_M

  • King Gator
  • Posts: 3949
  • C3D user & customizer
Re: VBA from 2k to 2k4
« Reply #15 on: July 19, 2006, 02:06:33 PM »
Here's a version (Budcad didn't say this was copyrighted material) that does not use ANY LDT references. Just create a new DVB file and add this to the ThisDrawing module:
Code: [Select]
Public Sub Blocks2Points()
On Error Resume Next
Dim AeccApplication As Object
    Select Case Int(Mid(ThisDrawing.GetVariable("ACADVER"), 1, 2))
        Case Is = 15
            Set AeccApplication = ThisDrawing.Application.GetInterfaceObject("Aecc.Application.2")
        Case Is = 16
            Set AeccApplication = ThisDrawing.Application.GetInterfaceObject("Aecc.Application.4")
        Case Is = 17
            Set AeccApplication = ThisDrawing.Application.GetInterfaceObject("Aecc.Application.6")
        Case Else
            MsgBox "This function not designed for use with this version. Exiting......"
            Exit Sub
    End Select
   
Dim AECProj As Object
    Set AECProj = AeccApplication.ActiveProject
Dim cogoPnts As Object
    Set cogoPnts = AECProj.CogoPoints

Dim newPnt As Variant

Set SSET = ThisDrawing.SelectionSets.Add("temp3")
SSET.SelectOnScreen
For Each ent In SSET
Select Case ent.EntityType
Case 7
array1 = ent.GetAttributes
newPnt = ent.InsertionPoint
cogoPnts.NextPointNumber = array1(0).TextString
Set newCogoPnt = cogoPnts.Add(newPnt, 2)
newCogoPnt.RawDescription = array1(1).TextString
newCogoPnt.Elevation = array1(2).TextString
End Select
Next
ThisDrawing.SelectionSets.Item("temp3").Delete
End Sub
I don't have a drawing to test this in, but I'm pretty sure it will work in any version of LDT from LDT2->LDT2007

Elgin

  • Guest
Re: VBA from 2k to 2k4
« Reply #16 on: July 19, 2006, 02:07:31 PM »
Thats the easy part that I've already accomplished. I am still getting an error that stops the macro from running. The error I recieve is shown in my post from earlier.

Jeff_M

  • King Gator
  • Posts: 3949
  • C3D user & customizer
Re: VBA from 2k to 2k4
« Reply #17 on: July 19, 2006, 02:26:58 PM »
What is the easy part??????

Post your dvb & drawing and I'll be better able to help you......

Elgin

  • Guest
Re: VBA from 2k to 2k4
« Reply #18 on: July 19, 2006, 02:47:57 PM »
the easy part was the checking unchecking the library. the not so easy part is the compile error i am getting. i also just tried to create the dvb as posted and it doesnt seem to work either. i added the text to the module as instructed but still got no points. it ran without error but didnt do anything with the points.

Jeff_M

  • King Gator
  • Posts: 3949
  • C3D user & customizer
Re: VBA from 2k to 2k4
« Reply #19 on: July 19, 2006, 02:59:07 PM »
I am still getting an error: "Compile Error: Can't find project or library." The portion of the code that is highlighted in grey is the third line 'Dim cogoPnts As AeccCogoPoints'. In yellow is the first line. What shall I do next?
The ONLY way that this error will show itself is if you do not have the proper Library Selected OR you are trying to run it in a non-LDT environment. You keep saying that this was the easy part, but this error indicates you have not done it.....sorry. Now, if you would like to send me a test drawing for me to make sure my modified code works I'll be happy to do so. You can either attach it here as a zip file or email it to me at miff@sonic.net

Jeff

Elgin

  • Guest
Re: VBA from 2k to 2k4
« Reply #20 on: July 19, 2006, 06:20:42 PM »
 8-) 8-) 8-) 8-)

Actually I had done it properly. The part i missed like a  :ugly: was that I didnt save the d@~##% thing or run it from within the edit window. Its now done and proper. I thank you guys majorly. Now....  who wants a beer? I'm buyin!!

Bob Wahr

  • Guest
Re: VBA from 2k to 2k4
« Reply #21 on: July 19, 2006, 06:27:36 PM »
I'm in.

Jeff_M

  • King Gator
  • Posts: 3949
  • C3D user & customizer
Re: VBA from 2k to 2k4
« Reply #22 on: July 19, 2006, 06:45:47 PM »
LOL, I wish I could say I have never done that.....but I will take you up on the beer! :-D