Solved

Entities and SelectionSets

Posted on 2006-11-13
2
736 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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Following a number of instances of re-installing Solidworks I thought that it may be a  good idea to detail the procedure that I follow each time to ensure a good stable install. Backup: Backup your system.  It goes without saying that this i…
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!…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 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

12 Experts available now in Live!

Get 1:1 Help Now