+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Forum Newbie
    Discipline
    Electro/Mech
    Using
    AutoCAD 2013
    Join Date
    Jul 2018
    Posts
    2

    Default Move Command Error

    Registered forum members do not see this ad.

    Hello, I am trying to make a script that will move items for me. I am importing anywhere from 2 to 9 drawings as Xrefs, then running this VBA script to move them based on the sheet number to a predefined spot for layout setups. The script is reading the names fine and making the point, but it is returning Runtime Error 5 on the move command, and I am not sure why. Any help would be appreciated.

    Thanks.

    Sample Code.jpg

  2. #2
    Forum Newbie
    Discipline
    Electro/Mech
    Using
    AutoCAD 2013
    Join Date
    Jul 2018
    Posts
    2

    Default

    Registered forum members do not see this ad.

    Sorry didn't see CODE formatting guidelines:

    Code:
    Sub DWG_Combine()
    'On Error Resume Next
    'Reads number of objects, moves them based on name, then creates layouts. Finally, explodes all for editing
    Dim i, NumObj, ObjID As Integer
    Dim SS1 As AcadSelectionSet
    Dim MspaceObj As AcadObject
    Dim p1(0 To 2), p2(0 To 2) As Double
    
    'set p1 as origin
    p1(0) = 0: p1(1) = 0: p1(2) = 0
    
    'selection set?
    If Err.Number <> 0 Then
        Set SS1 = ThisDrawing.SelectionSets.Add("SS1")
    End If
    
    'Counts number of objects
    NumObj = ThisDrawing.ModelSpace.Count
    'MsgBox NumObj
    
    
    i = 0
    
    'Cycles through each item in the modelspace, reads the ID number, and moves a multiple of the ID Number
    For Each Item In ThisDrawing.ModelSpace
        Set MspaceObj = ThisDrawing.ModelSpace.Item(i)
        'MsgBox MspaceObj.EffectiveName
        ObjID = Left(Right(MspaceObj.EffectiveName, 2), 1)
        'MsgBox objID
        p2(0) = (ObjID - 1) * 45: p2(1) = 0: p2(2) = 0
        MspaceObj.Move p1, p2
        i = i + 1
    Next
    
    End Sub

Similar Threads

  1. Move Command End Position Error (Assumed Precision/Floating Point Error)
    By 13lade001 in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 11th Mar 2017, 09:06 pm
  2. AutoLisp Error Handling - Command in Custom Error Causes Error
    By RonnieMoore in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 8th Nov 2013, 05:28 pm
  3. Error at the import Points option... and error in the open file command, need help...
    By ManAtWork in forum AutoCAD Bugs, Error Messages & Quirks
    Replies: 1
    Last Post: 13th Oct 2010, 06:42 pm
  4. AutoCAD 2007 Error "MOVE command does COPY" and a lot more
    By gauravmozar in forum AutoCAD Bugs, Error Messages & Quirks
    Replies: 3
    Last Post: 12th Jan 2010, 06:03 pm
  5. Move command
    By ALoock in forum AutoCAD Beginners' Area
    Replies: 12
    Last Post: 2nd Dec 2008, 03:02 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts