Jump to content

Copy Move and Scale in Autocad through VB.net


Gooner_4692

Recommended Posts

Hi everyone,

I'm relatively new to VB and AutoCAD, and I've been trying to incorporate a command line method into my existing code to copy, move, and scale a drawing. However, I've hit a roadblock and would appreciate some guidance.

Every time I try to run the code, I encounter an error stating "acdbmgd.dll not found." From what I understand, this seems to be related to a missing reference or dependency associated with AutoCAD libraries.

Here's  the code I've been working on:
 

Imports Autodesk.AutoCAD.Runtime

Imports Autodesk.AutoCAD.ApplicationServices

Imports Autodesk.AutoCAD.DatabaseServices

Imports Autodesk.AutoCAD.Geometry

Imports Autodesk.AutoCAD.EditorInput



Public Class SelectionSetClass



    <CommandMethod("SelectWindowAndCopy")>

    Public Sub SelectWindowAndCopy()

        Dim doc As Document = Application.DocumentManager.MdiActiveDocument

        Dim db As Database = doc.Database

        Dim edt As Editor = doc.Editor



        Using trans As Transaction = doc.TransactionManager.StartTransaction()

            Dim psr As PromptSelectionResult = edt.SelectWindow(New Point3d(36, 22, 0), New Point3d(149.5, 33, 0))



            If psr.Status = PromptStatus.OK Then

                Dim ss As SelectionSet = psr.Value



                ' Get the bottom-left corner of the window selection

                Dim windowBottomLeft As Point3d = New Point3d(35, 22, 0)



                For Each sobj As SelectedObject In ss

                    Dim ent As Entity = TryCast(trans.GetObject(sobj.ObjectId, OpenMode.ForWrite), Entity)



                    If Not ent Is Nothing Then

                        '' Create a copy of the selected entity

                        Dim entCopy As Entity = ent.Clone()  ' Create a copy of the entity



                        '' Calculate the translation vector to move the bottom-left corner of the entity to the origin

                        Dim translationVector As Vector3d = New Vector3d(-windowBottomLeft.X, -windowBottomLeft.Y, 0)



                        '' Apply the translation transformation

                        entCopy.TransformBy(Matrix3d.Displacement(translationVector))



                        '' Apply the scaling transformation

                        Dim scaleMatrix As Matrix3d = Matrix3d.Scaling(10, New Point3d(0, 0, 0))

                        entCopy.TransformBy(scaleMatrix)



                        '' Open the Block table for write

                        Dim acBlkTbl As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead)

                        Dim acBlkTblRec As BlockTableRecord = trans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)



                        '' Add the copied entity to the block table record

                        acBlkTblRec.AppendEntity(entCopy)

                        trans.AddNewlyCreatedDBObject(entCopy, True)

                    End If

                Next





            End If



            trans.Commit()

        End Using

    End Sub

End Class



 

I've tried researching this issue online, but I'm still unsure how to resolve it. Can anyone please provide insights on how I can properly reference the required AutoCAD libraries in my project settings to fix this error?

Any help or suggestions would be greatly appreciated.

Thank you in advance!

Edited by SLW210
Code Tags!
Link to comment
Share on other sites

acdbmgd.dll is associated with the DatabaseServices library. It's kind of important, because a drawing is basically a database full of objects.

 

See this discussion. If you're creating an EXE, you can't use .NET, if I'm reading it correctly. There is some good advice on how to work with VBA.

 

If that doesn't take care of your issue, please provide more information.

 

Welcome to the forum!

 

 

Link to comment
Share on other sites

Perhaps this discussion as well.

 

Quote

From taking programming classes led by some of the head developers from Autodesk they said to always reference the acmgd & acdbmgd dlls from the ObjectARX sdk (not the one delivered with the software) and to NOT deliver them with your own applications.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...