Jump to content

scaling in vb.net


Recommended Posts

Posted

I have a vbdotnet code to create a command which scales the drawing

Please see attached a print screen of the code

You will see that I am getting two errors.

How do I fix these errors.

How do I tweek the code so that it scales all objects in the drawing by 25.4.

cscaleall.doc

Posted (edited)

I am not familiar with VBA for AutoCAD but that is what it looks like, but

 

 

From AutoCAD .NET Developer's Guide in help

 

You move, scale, rotate and mirror an object using a 4 by 4 transformation matrix represented by a Matrix3d object and the TransformBy method

LINK

 

This LINK shows an example.

 

Here is scaling all objects in model space 25.4 using the origin as the base point

 

       <CommandMethod("ScaletoMetric")> _
       Public Sub ScaletoMetric()
           Dim doc As Document = Application.DocumentManager.MdiActiveDocument
           Dim ed As Editor = doc.Editor
           Dim db As Database = doc.Database

           Using trx As Transaction = db.TransactionManager.StartTransaction()

               Dim bt As BlockTable = trx.GetObject(db.BlockTableId, OpenMode.ForRead)
               Dim modelBtr As BlockTableRecord = trx.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForRead)

               For Each objId As ObjectId In modelBtr
                   Dim ent As Entity = trx.GetObject(objId, OpenMode.ForWrite)
                   ent.TransformBy(Matrix3d.Scaling(25.4, Point3d.Origin))
               Next

               trx.Commit()
           End Using
       End Sub

Edited by Jeff H
Posted

Thats perfect Jeff. Thanks for the code and the links

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...