in VBA code as follows in ACAD 2005 Windows XP Pro on this line >>> Set wedgeObj = ActiveDocument.ModelSpace.AddWedge(centerx, lengthx, widthx, heightx) It works in AutoCAD 2000 in Windows XP Pro ----------------------- Dim wedgeObj As Acad3DSolid Dim AcadObjs As Object Dim AcadDoc As Object Dim acadObj As Object Dim centerx(0 To 2) As Double Dim lengthx As Double Dim widthx As Double Dim heightx As Double Private Sub CommandButton1_Click() Set AcadObjs = GetObject(, "AutoCAD.Application") 'USED IN OLD R2000 CODE Set AcadDoc = AcadObjs.ActiveDocument centerx(0) = 0#: centerx(1) = 0#: centerx(2) = 0 lengthx = 10#: widthx = 10#: heightx = 20# Debug.Print "centers = "; centerx(0); " "; centerx(1); " "; centerx(2) Debug.Print "length = "; lengthx; " "; "width = "; widthx; " "; "height ="; heightx ' Create the wedge in model space Set wedgeObj = ActiveDocument.ModelSpace.AddWedge(centerx, lengthx, widthx, heightx) wedgeObj.Update
Maybe it's because it should read: Set wedgeObj = AcadDoc.ModelSpace.AddWedge(centerx, lengthx, widthx, heightx) But then again, it wouldn't work in 2000 either. So if it's not syntax then it should be that your AcadDoc is empty
Hi Jorge... My son came over (autocad wizard) an said that my AutoCad .dll was BAD... I had installed INVENTOR 9 Trail addition... I deleted off Inventor... autocad... others... R-Loaded AutoCad... WORKS PERFECTL... I wish to thank everyone for their assistances in my problems... THANKS...
If you're working in AutoCAD VBA, you don't need to connect to AutoCAD (i.e. you don't need the GetObject stuff). This code works for me in AutoCAD 2005: [pre] Public Sub DrawWedge() Dim Center(0 To 2) As Double Dim Height As Double Dim Length As Double Dim Wedge As Acad3DSolid Dim Width As Double Center(0) = 0# Center(1) = 0# Center(2) = 0# Length = 10# Width = 10# Height = 20# Set Wedge = ThisDrawing.ModelSpace.AddWedge(Center, Length, Width, Height) ThisDrawing.Application.ZoomExtents End Sub [/pre]