Solved

Entities and SelectionSets

Posted on 2006-11-13
2
737 Views
Last Modified: 2008-01-09
when I try to run this program I get a "Automation Error, Catastrophic Failure" error, stopping at the "for each ent in sset" like, can someone please help?

Dim sset As AcadSelectionSet

Private Sub UpdateFields()
    edtCount.Text = sset.Count & " Objekte"
    btGo.Enabled = (sset.Count > 0)
End Sub

Private Sub btGo_Click()
  UserForm1.hide
  Dim nowpt As AcadPoint
  Dim nowtx As AcadText
  Dim nowmtx As AcadMText
  Dim newpt(1 To 3) As Double
  Dim ent As AcadEntity
  For Each ent In sset
    If (TypeName(ent) = "IAcadText2") Then
      Set nowtx = ent
      newpt(1) = nowtx.InsertionPoint(0) + edtDX.Text
      newpt(2) = nowtx.InsertionPoint(1) + edtDY.Text
      newpt(3) = Trim(nowtx.TextString)
      ThisDrawing.ActiveLayer = CheckLayer("NEWPOINTS")
      ThisDrawing.ModelSpace.AddPoint newpt
    End If
    If (TypeName(ent) = "IAcadMText2") Then
      Set nowmtx = ent
      newpt(1) = nowmtx.InsertionPoint(0) + edtDX.Text
      newpt(2) = nowmtx.InsertionPoint(1) + edtDY.Text
      newpt(3) = Trim(nowmtx.TextString)
      ThisDrawing.ActiveLayer = CheckLayer("NEWPOINTS")
      ThisDrawing.ModelSpace.AddPoint newpt
    End If
  Next ent
  sset.Delete
End Sub

Private Sub CommandButton1_Click()
    UserForm1.hide
'    For I = 0 To ThisDrawing.SelectionSets.Count - 1
'        ThisDrawing.SelectionSets(I).Delete
'    Next I
    Set sset = ThisDrawing.SelectionSets.Add("MySetMP")
    sset.SelectOnScreen
    UpdateFields
    UserForm1.Show
End Sub

Private Sub CommandButton2_Click()
    sset.Clear
    UpdateFields
End Sub

Private Sub CommandButton4_Click()
    Me.hide
End Sub
0
Comment
Question by:simtech2007
2 Comments
 
LVL 14

Accepted Solution

by:
Tommy Kinard earned 125 total points
ID: 17947595
Hi simtech2007,

I see a couple of problems when I try to run this macro in 2000i.

edtDX.Text, edtDY.Text are not defined before use - at least in the code posted,

If (TypeName(ent) = "IAcadText2") Then

should be

If TypeOf ent Is AcadText Then

"Automation Error, Catastrophic Failure" error <-- may be because the sset object has not been created, check to see if it exists before use

dragontooth

0
 
LVL 1

Author Comment

by:simtech2007
ID: 17947670
YOU WON....

not because it's right, but I've found out that the catastrophic error was just a problem of AutoCAD itself, i.e. re-install and it's ok :)

but since you're the first who answered, you're the winner
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If, like me, you find yourself repeatedly and tediously joining many segments (lines, arcs) in other people's drawings back into polylines that can be used more effectively in Computer Aided Machining and Laser Cutting, then this article is for you!…
The following article will describe how to add/edit a dimension style through AutoCAD VBA. AutoCAD VBA has its quirks and when it comes to dimensions and controlling how they look through VBA.  This is where AutoCAD can be vividly confusing. The…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now