How to use a Copy Jig for an Entity Array

Anonymous

How to use a Copy Jig for an Entity Array

Anonymous
Not applicable

I am trying to copy various object type entities. Some entities are lines, circles, block references and polylines. After some time of searching and manipulating code that I found, I was able to find a copy jig for a single entity. My issue is I need it for an array of entities ...

 

Take a look at the CopyJig class that works for 1 entity (source😞

Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.DatabaseServices

Imports MgdAcApplication = Autodesk.AutoCAD.ApplicationServices.Application
Imports MgdAcDocument = Autodesk.AutoCAD.ApplicationServices.Document
Imports AcWindowsNS = Autodesk.AutoCAD.Windows

Public Class CopyJig
    Inherits EntityJig

 #Region "Fields"
    Public mCurJigFactorIndex As Integer = 1

    Private mBasePoint As New Point3d()
    Private mNewPoint As Point3d
    ' Factor #1
#End Region

#Region "Constructors"
    Public Sub New(ent As Entity, basePoint As Point3d)
        MyBase.New(ent)
        mNewPoint = InlineAssignHelper(mBasePoint, basePoint.TransformBy(UCS))
    End Sub
#End Region

#Region "Properties"
    Private ReadOnly Property Editor() As Editor
        Get
            Return MgdAcApplication.DocumentManager.MdiActiveDocument.Editor
        End Get
    End Property
    Private ReadOnly Property UCS() As Matrix3d
        Get
            Return Editor.CurrentUserCoordinateSystem
        End Get
    End Property
#End Region

#Region "Overrides"
    Protected Overrides Function Update() As Boolean
        Dim mat As Matrix3d = Matrix3d.Displacement(mBasePoint.GetVectorTo(mNewPoint))
        Entity.TransformBy(mat)
        mBasePoint = mNewPoint

        Return True
    End Function

    Protected Overrides Function Sampler(prompts As JigPrompts) As SamplerStatus
        Select Case mCurJigFactorIndex
            Case 1
                Dim prOptions1 As New JigPromptPointOptions(vbLf & "Location:")
                prOptions1.UserInputControls = UserInputControls.Accept3dCoordinates Or UserInputControls.GovernedByOrthoMode Or UserInputControls.GovernedByUCSDetect
                prOptions1.BasePoint = mBasePoint
                prOptions1.UseBasePoint = True
                Dim prResult1 As PromptPointResult = prompts.AcquirePoint(prOptions1)

                If prResult1.Status = PromptStatus.Cancel Then
                    Return SamplerStatus.Cancel
                End If

                If prResult1.Value.Equals(mNewPoint) Then
                    'Use better comparision method if wanted.
                    Return SamplerStatus.NoChange
                Else
                    mNewPoint = prResult1.Value
                    Return SamplerStatus.OK
                End If
            Case Else
                Exit Select
        End Select

        Return SamplerStatus.OK
    End Function

#End Region

#Region "Methods to Call"
    Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
        target = value
        Return value
    End Function
    Public Shared Function Jig(ent As Entity, basePt As Point3d) As Boolean
        Dim jigger As CopyJig = Nothing
        Try
            jigger = New CopyJig(ent, basePt)
            Dim pr As PromptResult
            Do
                pr = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor.Drag(jigger)
                ' Add keyword handling code below

                If pr.Status = PromptStatus.Keyword Then
                Else
                    jigger.mCurJigFactorIndex += 1
                End If
            Loop While pr.Status <> PromptStatus.Cancel AndAlso pr.Status <> PromptStatus.[Error] AndAlso jigger.mCurJigFactorIndex <= 1

            If pr.Status = PromptStatus.Cancel OrElse pr.Status = PromptStatus.[Error] Then
                If jigger IsNot Nothing AndAlso jigger.Entity IsNot Nothing Then
                    jigger.Entity.Dispose()
                End If

                Return False
            Else
                Return True
            End If
        Catch
            If jigger IsNot Nothing AndAlso jigger.Entity IsNot Nothing Then
                jigger.Entity.Dispose()
            End If

            Return False
        End Try
    End Function
#End Region

End Class

 

The following class is called using this code:

<CommandMethod("CopyEntities")> _
Public Sub CopyEntities()
    Dim ed As Editor = AcApp.DocumentManager.MdiActiveDocument.Editor
    Dim db As Database = HostApplicationServices.WorkingDatabase
    Dim rb As ResultBuffer
    Dim FoundCorrectXData As Boolean
    Dim Lst_ObjId As New List(Of ObjectId)
    Dim acBlkTbl As BlockTable
    Dim acBlkTblRec As BlockTableRecord
    Dim SelSet As SelectionSet = Nothing
    Dim entities As Entity()

    Try
        Dim selRes As PromptEntityResult = ed.GetEntity(vbLf & "Pick an entity:")
        Dim ptRes As PromptPointResult = ed.GetPoint(vbLf & "Base Point: ")
        If selRes.Status = PromptStatus.OK AndAlso ptRes.Status = PromptStatus.OK Then

            Using tr As Transaction = db.TransactionManager.StartTransaction()
                '------------------------- START BUILDING THE ARRAY OF ENTITIES---------------------
                rb = New ResultBuffer
                rb = selRes.ObjectId.GetObject(OpenMode.ForRead).XData()

                If IsHunter(rb) Then
                    MyObject.SetByDataTable(GetPKFromResultBuffer(rb), Project.PK_Project)
                    acBlkTbl = tr.GetObject(db.BlockTableId, OpenMode.ForRead) 'Open the Block table for read 
                    acBlkTblRec = tr.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite) 'Open the Block table record Model space for write 

                    'Go through the Block Table Record and build the collection ID
                    For Each acObjId As ObjectId In acBlkTblRec
                        rb = New ResultBuffer
                        rb = acObjId.GetObject(OpenMode.ForRead).XData()
                        FoundCorrectXData = False

                        If Not rb Is Nothing Then
                            For Each tv As TypedValue In rb
                                If tv.TypeCode = DxfCode.ExtendedDataRegAppName Then
                                    If tv.Value = "OBJECT_TO_BE_FOUND" Then FoundCorrectXData = True
                                End If
                                If FoundCorrectXData And tv.TypeCode = DxfCode.ExtendedDataInteger32 Then
                                    If tv.Value = MyObject.PK_MyObject Then
                                        Lst_ObjId.Add(acObjId)
                                        Exit For
                                    End If
                                End If
                            Next

                            rb.Dispose()
                        End If
                    Next

                    'Create a selection set from the object IDs added to the list
                    SelSet = SelectionSet.FromObjectIds(Lst_ObjId.ToArray)
                    entities = New Entity(SelSet.Count - 1) {}

                    'Create an array of entities
                    For i As Integer = 0 To SelSet.Count - 1
                        entities(i) = DirectCast(tr.GetObject(SelSet(i).ObjectId, OpenMode.ForWrite), Entity)
                    Next
                    '-----------------------------END OF ENTITY ARRAY BUILD----------------------------------

                    'Code used to clone a single entity
                    Dim ent As Entity = TryCast(tr.GetObject(selRes.ObjectId, OpenMode.ForRead), Entity)
                    If ent IsNot Nothing Then
                        Dim clone As Entity = TryCast(ent.Clone(), Entity)
                        If CopyJig.Jig(clone, ptRes.Value) Then
                            Dim ms As BlockTableRecord = TryCast(tr.GetObject(ent.OwnerId, OpenMode.ForWrite), BlockTableRecord)
                            If ms IsNot Nothing Then
                                ms.AppendEntity(clone)
                                tr.AddNewlyCreatedDBObject(clone, True)
                                tr.Commit()
                            End If
                        Else
                            tr.Abort()
                        End If
                    End If
                End If
            End Using
        End If
    Catch ex As System.Exception
        ed.WriteMessage(ex.ToString())
    End Try
End Sub

 

The goal is to be able to see where I'm copying my entities and be able to select that point. I cleaned up the code above from my CopyEntities method. It includes an array of entities that contain the perfect selection that I wanted. I've been trying to pass this into the CopyJig class but I keep hitting snags. 

 

My main snag is in the constructor of the CopyJig, I cannot pass an array of entities in there...

 

I thank you for the help in advance,

Alex

 

0 Likes
Reply
Accepted solutions (1)
4,185 Views
8 Replies
Replies (8)

norman.yuan
Mentor
Mentor

In most cases of jigging multiple entities, your custom Jig would be better off to derive from DrawJig, rather than EntityJig. However, there is very minor difference between the two in terms the purpose of jigging: providing visual feedback to user's mouse move.

 

If you insist to use EntityJig, you can simply make your custom jig's constructor like this:

 

Private myEntities() As Entity

Private myBasePoint As Point3d

 

Public Sub New MyCopyJig(ents As Entitys(), basePoint As Point3d)

    MyBase(Nothing)

   ''stored the passed entity array in a private member field here

   myEntities=ents

   myBasePoint=basePoint

End Sub

 

Of course, this EntityJig derived Jib object will have its Entity property equals null, but it will not matter, because you do not need it anyway.

 

Then in the overriden Update() method, you will transform the array of entities instead of a single entity. Do not forget to dispose the array of cloned entities, if the jiging is cancelled.

Norman Yuan

Drive CAD With Code

EESignature

Anonymous
Not applicable

Thank you for the feedback norman. After messing around with both DrawJig and EntityJig I decided to go for the DrawJig as you mentioned. I'm almost there! I'll be posting the solution once I get it figured out - or ask for some pointers if I can't get this last bit solved.

 

Very appreciated.

0 Likes

Anonymous
Not applicable

Here's the new version I started coding that inherits DrawJig. Now, for some reason, it copies the entities correctly but the mLocation (or destination point3d) is not correct. It is set correctly during the sampler but then becomes (0,0,0) once I click on the desired destination. It seems to be copying it over the existing entities that I selected to copy from.

 

Here's my CopyJig_2.vb class:

Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.DatabaseServices
Imports AcApp = Autodesk.AutoCAD.ApplicationServices.Application

Public Class CopyJig_2
    Inherits DrawJig

#Region "Fields"
    Private entities As Entity()
    Private mBase As Point3d
    Private mLocation As Point3d
    Public mCurJigFactorIndex As Integer = 1
#End Region

#Region "Constructors"
    Public Sub New(ents As Entity(), basePt As Point3d)
        entities = ents
        mBase = basePt.TransformBy(UCS)
    End Sub
#End Region

#Region "Properties"
    Public Property Location() As Point3d
        Get
            Return mLocation
        End Get
        Set(value As Point3d)
            mLocation = value
        End Set
    End Property
    Public ReadOnly Property UCS() As Matrix3d
        Get
            Return AcApp.DocumentManager.MdiActiveDocument.Editor.CurrentUserCoordinateSystem
        End Get
    End Property
#End Region

#Region "Methods"
    Public Sub TransformEntities()
        Dim mat As Matrix3d = Matrix3d.Displacement(mBase.GetVectorTo(mLocation))
        Dim line As Line
        Dim pLine As Polyline
        Dim startPoint As Point3d
        Dim endPoint As Point3d

        For Each ent As Entity In entities
            ent.TransformBy(mat)

            'Store main line / polyline for database information
            If ent.Handle.ToString = MyObject.Handle.ToString Then
                If TypeOf ent Is Line Then
                    line = DirectCast(ent, Line)
                    startPoint = line.StartPoint
                    endPoint = line.EndPoint
                ElseIf TypeOf ent Is Polyline Then
                    pLine = DirectCast(ent, Polyline)
                    startPoint = pLine.StartPoint
                    endPoint = pLine.EndPoint
                End If

'Set the primary key to -1 so that it creates another instance of the copied item MyObject.PK_MyObject = -1 MyObject.StartX = startPoint.X MyObject.StartY = startPoint.Y MyObject.EndX = endPoint.X MyObject.EndY = endPoint.Y MyObject.Update() End If Next End Sub Public Function Jig(ents As Entity(), basePt As Point3d) As Boolean Dim jigger As CopyJig_2 = Nothing Try jigger = New CopyJig_2(ents, basePt) Dim pr As PromptResult Do pr = AcApp.DocumentManager.MdiActiveDocument.Editor.Drag(jigger) ' Add keyword handling code below If pr.Status = PromptStatus.Keyword Then Else jigger.mCurJigFactorIndex += 1 End If Loop While pr.Status <> PromptStatus.Cancel AndAlso pr.Status <> PromptStatus.[Error] AndAlso jigger.mCurJigFactorIndex <= 1 If pr.Status = PromptStatus.Cancel OrElse pr.Status = PromptStatus.[Error] Then For Each e As Entity In ents If jigger IsNot Nothing AndAlso e IsNot Nothing Then e.Dispose() End If Next Return False Else Return True End If Catch For Each e As Entity In ents If jigger IsNot Nothing AndAlso e IsNot Nothing Then e.Dispose() End If Next Return False End Try End Function #End Region #Region "Overrides" Protected Overrides Function WorldDraw(draw As Autodesk.AutoCAD.GraphicsInterface.WorldDraw) As Boolean Dim mat As Matrix3d = Matrix3d.Displacement(mBase.GetVectorTo(mLocation)) Dim geo As Autodesk.AutoCAD.GraphicsInterface.WorldGeometry = draw.Geometry If geo IsNot Nothing Then geo.PushModelTransform(mat) For Each ent As Entity In entities geo.Draw(ent) Next geo.PopModelTransform() End If Return True End Function Protected Overrides Function Sampler(prompts As JigPrompts) As SamplerStatus Select Case mCurJigFactorIndex Case 1 Dim prOptions1 As New JigPromptPointOptions(vbLf & "Location:") prOptions1.UserInputControls = UserInputControls.Accept3dCoordinates Or UserInputControls.GovernedByOrthoMode Or UserInputControls.GovernedByUCSDetect prOptions1.BasePoint = mBase prOptions1.UseBasePoint = True Dim prResult1 As PromptPointResult = prompts.AcquirePoint(prOptions1) If prResult1.Status = PromptStatus.Cancel Then Return SamplerStatus.Cancel End If If prResult1.Value.Equals(mLocation) Then 'Use better comparision method if wanted. Return SamplerStatus.NoChange Else mLocation = prResult1.Value Return SamplerStatus.OK End If Case Else Exit Select End Select Return SamplerStatus.OK End Function #End Region End Class

 

Here is my command code, I'll shorten it because the majority of it is me filling up the entities array:

Dim cJig As New CopyJig_2(entities, pointResult.Value)

If cJig.Jig(entities, pointResult.Value) Then
    For Each e As Entity In entities
        clone = TryCast(e.Clone, Entity)
        acBlkTblRec.AppendEntity(clone)
        acTrans.AddNewlyCreatedDBObject(clone, True)
    Next

    acTrans.Commit()
Else
    acTrans.Abort()
End If

 

Any idea why I can't keep the value in mLocation?

0 Likes

_gile
Consultant
Consultant

Hi

 

There's a simpler solution to drag several entities with the overload Editor.Drag(PromptDragOptions) or Editor.Drag(SelectionSet, string, DragCallback) methods. The two methods are similar as the PromptDragOptions constructor requires the same arguments as the second method.

If you're not starting with a selection set, you can build one from an ObjectId array with the static (Shared) SelectionSet.FromObjectIds(ObjectId[]) method.

 

Here a little example which mimics the MOVE command.

 

C#

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;

namespace CsMoveSelectionSet
{
    public class Commands
    {
        Point3d _basePoint;

        [CommandMethod("Test")]
        public void Test()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            PromptSelectionResult psr = ed.GetSelection();
            if (psr.Status != PromptStatus.OK)
                return;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                List<Entity> ents = new List<Entity>();
                foreach (ObjectId id in psr.Value.GetObjectIds())
                {
                    Entity ent = (Entity)tr.GetObject(id, OpenMode.ForWrite);
                    ent.Highlight();
                    ents.Add(ent);
                }

                PromptPointOptions ppo = new PromptPointOptions("\nBase point: ");
                ppo.AllowNone = true;
                PromptPointResult ppr = ed.GetPoint(ppo);
                if (ppr.Status != PromptStatus.OK)
                    return;
                Matrix3d ucs = ed.CurrentUserCoordinateSystem;
                Point3d basePoint = ppr.Value.TransformBy(ucs);

                PromptDragOptions pdo = new PromptDragOptions(
                    psr.Value,
                    "\nSecond point: ",
                    delegate(Point3d pt, ref Matrix3d xform)
                    {
                        if (pt.IsEqualTo(basePoint))
                        {
                            return SamplerStatus.NoChange;
                        }
                        else
                        {
                            xform = Matrix3d.Displacement(basePoint.GetVectorTo(pt.TransformBy(ucs)));
                            return SamplerStatus.OK;
                        }
                    });
                pdo.AllowNone = true;

                ppr = ed.Drag(pdo);

                if (ppr.Status == PromptStatus.OK)
                {
                    Matrix3d mat = Matrix3d.Displacement(basePoint.GetVectorTo(ppr.Value.TransformBy(ucs)));
                    foreach (Entity ent in ents)
                    {
                        ent.TransformBy(mat);
                    }
                }

                else
                {
                    foreach (Entity ent in ents)
                    {
                        ent.Unhighlight();
                    }
                }
                tr.Commit();
            }
        }
    }
}

 

F#

module FsMoveSelectionSet

open Autodesk.AutoCAD.ApplicationServices
open Autodesk.AutoCAD.DatabaseServices
open Autodesk.AutoCAD.EditorInput
open Autodesk.AutoCAD.Geometry
open Autodesk.AutoCAD.Runtime

[<CommandMethod("Test")>]
let test () =
    let doc = Application.DocumentManager.MdiActiveDocument
    let db = doc.Database
    let ed = doc.Editor

    let psr = ed.GetSelection()
    if psr.Status = PromptStatus.OK then
        use tr = db.TransactionManager.StartTransaction()
        let ents = psr.Value.GetObjectIds() 
                   |> Array.map(fun id ->  tr.GetObject(id, OpenMode.ForWrite) :?> Entity)
        ents |> Array.iter(fun ent -> ent.Highlight())

        let ppo = new PromptPointOptions("\nBase point: ")
        ppo.AllowNone <- true
        let ppr = ed.GetPoint(ppo)
        if ppr.Status = PromptStatus.OK then
            let ucs = ed.CurrentUserCoordinateSystem
            let basePoint = ppr.Value.TransformBy(ucs)  

            let pdo = new PromptDragOptions(
                        psr.Value,  
                        "\nSecond point: ", 
                        fun pt (xform: Matrix3d byref) ->
                            if pt.IsEqualTo(basePoint) then
                                SamplerStatus.NoChange
                            else
                                xform <- Matrix3d.Displacement(basePoint.GetVectorTo(pt.TransformBy(ucs)))
                                SamplerStatus.OK)
            pdo.AllowNone <- true

            let ppr = ed.Drag(pdo)

            if ppr.Status = PromptStatus.OK then
                let xform = Matrix3d.Displacement(basePoint.GetVectorTo(ppr.Value.TransformBy(ucs)))
                ents |> Array.iter(fun ent -> ent.TransformBy(xform))
            else
                ents |> Array.iter(fun ent -> ent.Unhighlight())
        tr.Commit()

 

VB

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Runtime

Namespace VbMoveSelectionSet

    Public Class Commands

        Private basePoint As Point3d

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

            Dim psr As PromptSelectionResult = ed.GetSelection()
            If psr.Status <> PromptStatus.OK Then
                Return
            End If
            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim ents As New List(Of Entity)()
                For Each id As ObjectId In psr.Value.GetObjectIds()
                    Dim ent As Entity = DirectCast(tr.GetObject(id, OpenMode.ForWrite), Entity)
                    ent.Highlight()
                    ents.Add(ent)
                Next

                Dim ppo As New PromptPointOptions(vbLf & "Base point: ")
                ppo.AllowNone = True
                Dim ppr As PromptPointResult = ed.GetPoint(ppo)
                If ppr.Status <> PromptStatus.OK Then
                    Return
                End If
                Dim ucs As Matrix3d = ed.CurrentUserCoordinateSystem
                basePoint = ppr.Value.TransformBy(ucs)

                Dim pdo As New PromptDragOptions(psr.Value, vbLf & "Second point: ", AddressOf Callback)
                pdo.AllowNone = True

                ppr = ed.Drag(pdo)

                If ppr.Status = PromptStatus.OK Then
                    Dim mat As Matrix3d = Matrix3d.Displacement(basePoint.GetVectorTo(ppr.Value.TransformBy(ucs)))
                    For Each ent As Entity In ents
                        ent.TransformBy(mat)
                        ent.Unhighlight()
                    Next
                Else
                    For Each ent As Entity In ents
                        ent.Unhighlight()
                    Next
                End If

                tr.Commit()
            End Using
        End Sub

        Private Function Callback(ByVal pt As Point3d, ByRef xform As Matrix3d) As SamplerStatus
            If pt.IsEqualTo(basePoint) Then
                Return SamplerStatus.NoChange
            Else
                Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
                Dim ucs As Matrix3d = ed.CurrentUserCoordinateSystem
                xform = Matrix3d.Displacement(basePoint.GetVectorTo(pt.TransformBy(ucs)))
                Return SamplerStatus.OK
            End If
        End Function

    End Class

End Namespace

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

_gile
Consultant
Consultant

A Copy method using the same way

 

C#

        private ObjectIdCollection Copy(Database db, Editor ed, ObjectIdCollection source)
        {
            ObjectIdCollection copied = new ObjectIdCollection();

            PromptPointResult result = ed.GetPoint("\nBase point: ");
            if (result.Status != PromptStatus.OK)
                return copied;

            Matrix3d ucs = ed.CurrentUserCoordinateSystem;
            Point3d basePoint = result.Value.TransformBy(ucs);

            using (IdMapping idMap = new IdMapping())
            {
                db.DeepCloneObjects(source, db.CurrentSpaceId, idMap, false);
                foreach (IdPair pair in idMap)
                {
                    if (pair.IsPrimary && pair.IsCloned)
                        copied.Add(pair.Value);
                }
            }

            ObjectId[] ids = new ObjectId[copied.Count];
            copied.CopyTo(ids, 0);

            SelectionSet selSet = SelectionSet.FromObjectIds(ids);

            Matrix3d disp = new Matrix3d();

            DragCallback callback = (Point3d current, ref Matrix3d xform) =>
                {
                    Point3d pt = current.TransformBy(ucs);
                    if (pt.IsEqualTo(basePoint)) return SamplerStatus.NoChange;
                    disp = xform = Matrix3d.Displacement(basePoint.GetVectorTo(pt));
                    return SamplerStatus.OK;
                };

            result = ed.Drag(selSet, "\nSecond point: ", callback);

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                var ents = ids.Select(id => (Entity)tr.GetObject(id, OpenMode.ForWrite));
                if (result.Status == PromptStatus.OK)
                {
                    foreach (Entity ent in ents)
                    {
                        ent.TransformBy(disp);
                    }
                }
                else
                {
                    foreach (Entity ent in ents)
                    {
                        ent.Erase();
                    }
                    copied.Clear();
                }
                tr.Commit();
            }
            return copied;
        }

 

VB

        Private Function Copy(db As Database, ed As Editor, source As ObjectIdCollection) As ObjectIdCollection

            Dim copied As ObjectIdCollection = New ObjectIdCollection()

            Dim result As PromptPointResult = ed.GetPoint(vbLf & "Base point: ")
            If result.Status <> PromptStatus.OK Then
                Return copied
            End If

            Dim ucs As Matrix3d = ed.CurrentUserCoordinateSystem
            Dim basePoint As Point3d = result.Value

            Using idMap As IdMapping = New IdMapping()
                db.DeepCloneObjects(source, db.CurrentSpaceId, idMap, False)
                For Each pair As IdPair In idMap
                    If pair.IsPrimary AndAlso pair.IsCloned Then
                        copied.Add(pair.Value)
                    End If
                Next
            End Using

            Dim ids(copied.Count - 1) As ObjectId
            copied.CopyTo(ids, 0)

            Dim selSet As SelectionSet = SelectionSet.FromObjectIds(ids)

            Dim disp As Matrix3d = New Matrix3d()

            Dim callback As DragCallback = _
                Function(current As Point3d, ByRef xform As Matrix3d)
                    Dim pt As Point3d = current.TransformBy(ucs)
                    If current.IsEqualTo(basePoint) Then
                        Return SamplerStatus.NoChange
                    Else
                        xform = Matrix3d.Displacement(basePoint.GetVectorTo(pt))
                        disp = xform
                        Return SamplerStatus.OK
                    End If
                End Function

            result = ed.Drag(selSet, vbLf & "Second point: ", callback)

            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim ents As IEnumerable(Of Entity) = _
                    From id In ids Select DirectCast(tr.GetObject(id, OpenMode.ForWrite), Entity)
                If result.Status = PromptStatus.OK Then
                    For Each ent As Entity In ents
                        ent.TransformBy(disp)
                    Next
                Else
                    For Each ent As Entity In ents
                        ent.Erase()
                    Next
                    copied.Clear()
                End If
                tr.Commit()
            End Using

            Return copied

        End Function

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

_gile
Consultant
Consultant

Here's a better implementation of the previous method.

 

C#

private ObjectIdCollection Copy(Database db, Editor ed, ObjectId[] source)
{
    ObjectIdCollection copied = new ObjectIdCollection();

    PromptPointResult result = ed.GetPoint("\nBase point: ");
    if (result.Status != PromptStatus.OK)
        return copied;

    Matrix3d ucs = ed.CurrentUserCoordinateSystem;
    Point3d basePoint = result.Value.TransformBy(ucs);

    SelectionSet selSet = SelectionSet.FromObjectIds(source);

    Matrix3d disp = new Matrix3d();

    DragCallback callback = (Point3d current, ref Matrix3d xform) =>
    {
        Point3d pt = current.TransformBy(ucs);
        if (pt.IsEqualTo(basePoint)) return SamplerStatus.NoChange;
        disp = xform = Matrix3d.Displacement(basePoint.GetVectorTo(pt));
        return SamplerStatus.OK;
    };

    result = ed.Drag(selSet, "\nSecond point: ", callback);

    if (result.Status == PromptStatus.OK)
    {
        using (Transaction tr = db.TransactionManager.StartTransaction())
        using (IdMapping idMap = new IdMapping())
        {
            db.DeepCloneObjects(new ObjectIdCollection(source), db.CurrentSpaceId, idMap, false);
            foreach (IdPair pair in idMap)
            {
                if (pair.IsPrimary && pair.IsCloned)
                {
                    copied.Add(pair.Value);
                    Entity ent = (Entity)tr.GetObject(pair.Value, OpenMode.ForWrite);
                    ent.TransformBy(disp);
                }
            }
            tr.Commit();
        }
    }
    return copied;
}

 

VB

Private Function Copy(db As Database, ed As Editor, source As ObjectId()) As ObjectIdCollection

    Dim copied As ObjectIdCollection = New ObjectIdCollection()

    Dim result As PromptPointResult = ed.GetPoint(vbLf & "Base point: ")
    If result.Status = PromptStatus.OK Then
        Dim ucs As Matrix3d = ed.CurrentUserCoordinateSystem
        Dim basePoint As Point3d = result.Value

        Dim selSet As SelectionSet = SelectionSet.FromObjectIds(source)

        Dim disp As Matrix3d = New Matrix3d()

        Dim callback As DragCallback = _
            Function(current As Point3d, ByRef xform As Matrix3d)
                Dim pt As Point3d = current.TransformBy(ucs)
                If current.IsEqualTo(basePoint) Then
                    Return SamplerStatus.NoChange
                Else
                    xform = Matrix3d.Displacement(basePoint.GetVectorTo(pt))
                    disp = xform
                    Return SamplerStatus.OK
                End If
            End Function

        result = ed.Drag(selSet, vbLf & "Second point: ", callback)
        If result.Status = PromptStatus.OK Then
            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Using idMap As IdMapping = New IdMapping()
                    db.DeepCloneObjects(New ObjectIdCollection(source), db.CurrentSpaceId, idMap, False)
                    For Each pair As IdPair In idMap
                        If pair.IsPrimary AndAlso pair.IsCloned Then
                            copied.Add(pair.Value)
                            Dim ent As Entity = DirectCast(tr.GetObject(pair.Value, OpenMode.ForWrite), Entity)
                            ent.TransformBy(disp)
                        End If
                    Next
                End Using
                tr.Commit()
            End Using
        End If
    End If

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

_gile
Consultant
Consultant
Accepted solution

If you rather use a DrawJig derived class, you have to transform the entities (the DrawJig only draws transformed geometries).

 

C#

the CopyJig class

        class CopyJig : DrawJig
        {
            Point3d basePoint, dragPoint;
            Matrix3d xform;
            Entity[] entities;

            public CopyJig(IEnumerable<Entity> ents, Point3d basePoint)
            {
                this.basePoint = basePoint;
                this.entities = ents.ToArray();
            }

            public Matrix3d Transform { get { return xform; } }

            protected override bool WorldDraw(WorldDraw draw)
            {
                WorldGeometry wg = draw.Geometry;
                xform = Matrix3d.Displacement(basePoint.GetVectorTo(dragPoint));
                wg.PushModelTransform(xform);
                foreach (Entity ent in entities)
                {
                    wg.Draw(ent);
                }
                wg.PopModelTransform();
                return true;
            }

            protected override SamplerStatus Sampler(JigPrompts prompts)
            {
                JigPromptPointOptions options = new JigPromptPointOptions("\nSecond point: ");
                options.BasePoint = basePoint;
                options.UseBasePoint = true;
                options.Cursor = CursorType.RubberBand;
                options.UserInputControls = UserInputControls.Accept3dCoordinates;
                PromptPointResult result = prompts.AcquirePoint(options);
                if (result.Value.IsEqualTo(dragPoint))
                    return SamplerStatus.NoChange;
                dragPoint = result.Value;
                return SamplerStatus.OK;
            }
        }

 the JigCopy method

        private ObjectIdCollection JigCopy(Database db, Editor ed, ObjectIdCollection source)
        {
            ObjectIdCollection copied = new ObjectIdCollection();
            Entity[] entities = new Entity[source.Count];

            PromptPointResult result = ed.GetPoint("\nBase point: ");
            if (result.Status != PromptStatus.OK)
                return copied;

            Matrix3d ucs = ed.CurrentUserCoordinateSystem;
            Point3d basePoint = result.Value.TransformBy(ucs);

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                for (int i = 0; i < source.Count; i++)
                {
                    entities[i] = (Entity)tr.GetObject(source[i], OpenMode.ForRead);
                }
                CopyJig jig = new CopyJig(entities, basePoint);
                PromptResult pr = ed.Drag(jig);
                if (pr.Status == PromptStatus.OK)
                {
                    Matrix3d xform = jig.Transform;
                    using (IdMapping idMap = new IdMapping())
                    {
                        db.DeepCloneObjects(source, db.CurrentSpaceId, idMap, false);
                        foreach (IdPair pair in idMap)
                        {
                            if (pair.IsPrimary && pair.IsCloned)
                            {
                                copied.Add(pair.Value);
                                Entity ent = (Entity)tr.GetObject(pair.Value, OpenMode.ForWrite);
                                ent.TransformBy(xform);
                            }
                        }
                    }
                }
                tr.Commit();
            }

            return copied;
        }

 

 

VB

the CopyJig class

        Private Class EntitiesJig
            Inherits DrawJig

            Private basePoint As Point3d
            Private dragPoint As Point3d
            Private xform As Matrix3d
            Private entities() As Entity

            Public Sub New(ents As IEnumerable(Of Entity), basePt As Point3d)
                basePoint = basePt
                entities = ents.ToArray()
            End Sub

            Public ReadOnly Property Transform() As Matrix3d
                Get
                    Return xform
                End Get
            End Property

            Protected Overrides Function Sampler(prompts As JigPrompts) As SamplerStatus
                Dim options As JigPromptPointOptions = New JigPromptPointOptions(vbLf & "Second point: ")
                options.BasePoint = basePoint
                options.UseBasePoint = True
                options.Cursor = CursorType.RubberBand
                options.UserInputControls = UserInputControls.Accept3dCoordinates
                Dim result As PromptPointResult = prompts.AcquirePoint(options)
                If result.Value.IsEqualTo(dragPoint) Then
                    Return SamplerStatus.NoChange
                End If
                dragPoint = result.Value
                Return SamplerStatus.OK
            End Function

            Protected Overrides Function WorldDraw(draw As WorldDraw) As Boolean
                Dim wg As WorldGeometry = draw.Geometry
                xform = Matrix3d.Displacement(basePoint.GetVectorTo(dragPoint))
                wg.PushModelTransform(xform)
                For Each entity As Entity In entities
                    wg.Draw(entity)
                Next
                wg.PopModelTransform()
                Return True
            End Function
        End Class

 the JigCopy method

        Private Function JigCopy(db As Database, ed As Editor, source As ObjectIdCollection) As ObjectIdCollection

            Dim copied As ObjectIdCollection = New ObjectIdCollection()
            Dim entities(source.Count - 1) As Entity

            Dim result As PromptPointResult = ed.GetPoint(vbLf & "Base point: ")
            If result.Status <> PromptStatus.OK Then
                Return copied
            End If

            Dim ucs As Matrix3d = ed.CurrentUserCoordinateSystem
            Dim basePoint As Point3d = result.Value.TransformBy(ucs)

            Using tr As Transaction = db.TransactionManager.StartTransaction()
                For i = 0 To source.Count - 1
                    entities(i) = DirectCast(tr.GetObject(source(i), OpenMode.ForRead), Entity)
                Next
                Dim jig As EntitiesJig = New EntitiesJig(entities, basePoint)
                Dim pr As PromptResult = ed.Drag(jig)
                If pr.Status = PromptStatus.OK Then
                    Dim xform As Matrix3d = jig.Transform
                    Using idMap As IdMapping = New IdMapping()
                        db.DeepCloneObjects(source, db.CurrentSpaceId, idMap, False)
                        For Each pair As IdPair In idMap
                            If pair.IsPrimary AndAlso pair.IsCloned Then
                                copied.Add(pair.Value)
                                Dim ent As Entity = _
                                    DirectCast(tr.GetObject(pair.Value, OpenMode.ForWrite), Entity)
                                ent.TransformBy(xform)
                            End If
                        Next
                    End Using
                End If
                tr.Commit()
            End Using

            Return copied

        End Function

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Anonymous
Not applicable
Excellent. It worked great!

Merci!
0 Likes

Type a product name

______
icon-svg-close-thick

Cookie preferences

Your privacy is important to us and so is an optimal experience. To help us customize information and build applications, we collect data about your use of this site.

May we collect and use your data?

Learn more about the Third Party Services we use and our Privacy Statement.

Strictly necessary – required for our site to work and to provide services to you

These cookies allow us to record your preferences or login information, respond to your requests or fulfill items in your shopping cart.

Improve your experience – allows us to show you what is relevant to you

These cookies enable us to provide enhanced functionality and personalization. They may be set by us or by third party providers whose services we use to deliver information and experiences tailored to you. If you do not allow these cookies, some or all of these services may not be available for you.

Customize your advertising – permits us to offer targeted advertising to you

These cookies collect data about you based on your activities and interests in order to show you relevant ads and to track effectiveness. By collecting this data, the ads you see will be more tailored to your interests. If you do not allow these cookies, you will experience less targeted advertising.

icon-svg-close-thick

THIRD PARTY SERVICES

Learn more about the Third-Party Services we use in each category, and how we use the data we collect from you online.

icon-svg-hide-thick

icon-svg-show-thick

Strictly necessary – required for our site to work and to provide services to you

Qualtrics
We use Qualtrics to let you give us feedback via surveys or online forms. You may be randomly selected to participate in a survey, or you can actively decide to give us feedback. We collect data to better understand what actions you took before filling out a survey. This helps us troubleshoot issues you may have experienced. Qualtrics Privacy Policy
Akamai mPulse
We use Akamai mPulse to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, and your Autodesk ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. Akamai mPulse Privacy Policy
Digital River
We use Digital River to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, and your Autodesk ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. Digital River Privacy Policy
Dynatrace
We use Dynatrace to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, and your Autodesk ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. Dynatrace Privacy Policy
Khoros
We use Khoros to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, and your Autodesk ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. Khoros Privacy Policy
Launch Darkly
We use Launch Darkly to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, and your Autodesk ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. Launch Darkly Privacy Policy
New Relic
We use New Relic to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, and your Autodesk ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. New Relic Privacy Policy
Salesforce Live Agent
We use Salesforce Live Agent to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, and your Autodesk ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. Salesforce Live Agent Privacy Policy
Wistia
We use Wistia to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, and your Autodesk ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. Wistia Privacy Policy
Tealium
We use Tealium to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. Tealium Privacy Policy
Upsellit
We use Upsellit to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. Upsellit Privacy Policy
CJ Affiliates
We use CJ Affiliates to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. CJ Affiliates Privacy Policy
Commission Factory
We use Commission Factory to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. Commission Factory Privacy Policy
Google Analytics (Strictly Necessary)
We use Google Analytics (Strictly Necessary) to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, and your Autodesk ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. Google Analytics (Strictly Necessary) Privacy Policy
Typepad Stats
We use Typepad Stats to collect data about your behaviour on our sites. This may include pages you’ve visited. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our platform to provide the most relevant content. This allows us to enhance your overall user experience. Typepad Stats Privacy Policy
Geo Targetly
We use Geo Targetly to direct website visitors to the most appropriate web page and/or serve tailored content based on their location. Geo Targetly uses the IP address of a website visitor to determine the approximate location of the visitor’s device. This helps ensure that the visitor views content in their (most likely) local language.Geo Targetly Privacy Policy
SpeedCurve
We use SpeedCurve to monitor and measure the performance of your website experience by measuring web page load times as well as the responsiveness of subsequent elements such as images, scripts, and text.SpeedCurve Privacy Policy
Qualified
Qualified is the Autodesk Live Chat agent platform. This platform provides services to allow our customers to communicate in real-time with Autodesk support. We may collect unique ID for specific browser sessions during a chat. Qualified Privacy Policy

icon-svg-hide-thick

icon-svg-show-thick

Improve your experience – allows us to show you what is relevant to you

Google Optimize
We use Google Optimize to test new features on our sites and customize your experience of these features. To do this, we collect behavioral data while you’re on our sites. This data may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, your Autodesk ID, and others. You may experience a different version of our sites based on feature testing, or view personalized content based on your visitor attributes. Google Optimize Privacy Policy
ClickTale
We use ClickTale to better understand where you may encounter difficulties with our sites. We use session recording to help us see how you interact with our sites, including any elements on our pages. Your Personally Identifiable Information is masked and is not collected. ClickTale Privacy Policy
OneSignal
We use OneSignal to deploy digital advertising on sites supported by OneSignal. Ads are based on both OneSignal data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that OneSignal has collected from you. We use the data that we provide to OneSignal to better customize your digital advertising experience and present you with more relevant ads. OneSignal Privacy Policy
Optimizely
We use Optimizely to test new features on our sites and customize your experience of these features. To do this, we collect behavioral data while you’re on our sites. This data may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, your Autodesk ID, and others. You may experience a different version of our sites based on feature testing, or view personalized content based on your visitor attributes. Optimizely Privacy Policy
Amplitude
We use Amplitude to test new features on our sites and customize your experience of these features. To do this, we collect behavioral data while you’re on our sites. This data may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, your Autodesk ID, and others. You may experience a different version of our sites based on feature testing, or view personalized content based on your visitor attributes. Amplitude Privacy Policy
Snowplow
We use Snowplow to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, and your Autodesk ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. Snowplow Privacy Policy
UserVoice
We use UserVoice to collect data about your behaviour on our sites. This may include pages you’ve visited. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our platform to provide the most relevant content. This allows us to enhance your overall user experience. UserVoice Privacy Policy
Clearbit
Clearbit allows real-time data enrichment to provide a personalized and relevant experience to our customers. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID.Clearbit Privacy Policy
YouTube
YouTube is a video sharing platform which allows users to view and share embedded videos on our websites. YouTube provides viewership metrics on video performance. YouTube Privacy Policy

icon-svg-hide-thick

icon-svg-show-thick

Customize your advertising – permits us to offer targeted advertising to you

Adobe Analytics
We use Adobe Analytics to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, and your Autodesk ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. Adobe Analytics Privacy Policy
Google Analytics (Web Analytics)
We use Google Analytics (Web Analytics) to collect data about your behavior on our sites. This may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. We use this data to measure our site performance and evaluate the ease of your online experience, so we can enhance our features. We also use advanced analytics methods to optimize your experience with email, customer support, and sales. Google Analytics (Web Analytics) Privacy Policy
AdWords
We use AdWords to deploy digital advertising on sites supported by AdWords. Ads are based on both AdWords data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that AdWords has collected from you. We use the data that we provide to AdWords to better customize your digital advertising experience and present you with more relevant ads. AdWords Privacy Policy
Marketo
We use Marketo to send you more timely and relevant email content. To do this, we collect data about your online behavior and your interaction with the emails we send. Data collected may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, email open rates, links clicked, and others. We may combine this data with data collected from other sources to offer you improved sales or customer service experiences, as well as more relevant content based on advanced analytics processing. Marketo Privacy Policy
Doubleclick
We use Doubleclick to deploy digital advertising on sites supported by Doubleclick. Ads are based on both Doubleclick data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that Doubleclick has collected from you. We use the data that we provide to Doubleclick to better customize your digital advertising experience and present you with more relevant ads. Doubleclick Privacy Policy
HubSpot
We use HubSpot to send you more timely and relevant email content. To do this, we collect data about your online behavior and your interaction with the emails we send. Data collected may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, email open rates, links clicked, and others. HubSpot Privacy Policy
Twitter
We use Twitter to deploy digital advertising on sites supported by Twitter. Ads are based on both Twitter data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that Twitter has collected from you. We use the data that we provide to Twitter to better customize your digital advertising experience and present you with more relevant ads. Twitter Privacy Policy
Facebook
We use Facebook to deploy digital advertising on sites supported by Facebook. Ads are based on both Facebook data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that Facebook has collected from you. We use the data that we provide to Facebook to better customize your digital advertising experience and present you with more relevant ads. Facebook Privacy Policy
LinkedIn
We use LinkedIn to deploy digital advertising on sites supported by LinkedIn. Ads are based on both LinkedIn data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that LinkedIn has collected from you. We use the data that we provide to LinkedIn to better customize your digital advertising experience and present you with more relevant ads. LinkedIn Privacy Policy
Yahoo! Japan
We use Yahoo! Japan to deploy digital advertising on sites supported by Yahoo! Japan. Ads are based on both Yahoo! Japan data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that Yahoo! Japan has collected from you. We use the data that we provide to Yahoo! Japan to better customize your digital advertising experience and present you with more relevant ads. Yahoo! Japan Privacy Policy
Naver
We use Naver to deploy digital advertising on sites supported by Naver. Ads are based on both Naver data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that Naver has collected from you. We use the data that we provide to Naver to better customize your digital advertising experience and present you with more relevant ads. Naver Privacy Policy
Quantcast
We use Quantcast to deploy digital advertising on sites supported by Quantcast. Ads are based on both Quantcast data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that Quantcast has collected from you. We use the data that we provide to Quantcast to better customize your digital advertising experience and present you with more relevant ads. Quantcast Privacy Policy
Call Tracking
We use Call Tracking to provide customized phone numbers for our campaigns. This gives you faster access to our agents and helps us more accurately evaluate our performance. We may collect data about your behavior on our sites based on the phone number provided. Call Tracking Privacy Policy
Wunderkind
We use Wunderkind to deploy digital advertising on sites supported by Wunderkind. Ads are based on both Wunderkind data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that Wunderkind has collected from you. We use the data that we provide to Wunderkind to better customize your digital advertising experience and present you with more relevant ads. Wunderkind Privacy Policy
ADC Media
We use ADC Media to deploy digital advertising on sites supported by ADC Media. Ads are based on both ADC Media data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that ADC Media has collected from you. We use the data that we provide to ADC Media to better customize your digital advertising experience and present you with more relevant ads. ADC Media Privacy Policy
AgrantSEM
We use AgrantSEM to deploy digital advertising on sites supported by AgrantSEM. Ads are based on both AgrantSEM data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that AgrantSEM has collected from you. We use the data that we provide to AgrantSEM to better customize your digital advertising experience and present you with more relevant ads. AgrantSEM Privacy Policy
Bidtellect
We use Bidtellect to deploy digital advertising on sites supported by Bidtellect. Ads are based on both Bidtellect data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that Bidtellect has collected from you. We use the data that we provide to Bidtellect to better customize your digital advertising experience and present you with more relevant ads. Bidtellect Privacy Policy
Bing
We use Bing to deploy digital advertising on sites supported by Bing. Ads are based on both Bing data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that Bing has collected from you. We use the data that we provide to Bing to better customize your digital advertising experience and present you with more relevant ads. Bing Privacy Policy
G2Crowd
We use G2Crowd to deploy digital advertising on sites supported by G2Crowd. Ads are based on both G2Crowd data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that G2Crowd has collected from you. We use the data that we provide to G2Crowd to better customize your digital advertising experience and present you with more relevant ads. G2Crowd Privacy Policy
NMPI Display
We use NMPI Display to deploy digital advertising on sites supported by NMPI Display. Ads are based on both NMPI Display data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that NMPI Display has collected from you. We use the data that we provide to NMPI Display to better customize your digital advertising experience and present you with more relevant ads. NMPI Display Privacy Policy
VK
We use VK to deploy digital advertising on sites supported by VK. Ads are based on both VK data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that VK has collected from you. We use the data that we provide to VK to better customize your digital advertising experience and present you with more relevant ads. VK Privacy Policy
Adobe Target
We use Adobe Target to test new features on our sites and customize your experience of these features. To do this, we collect behavioral data while you’re on our sites. This data may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, your IP address or device ID, your Autodesk ID, and others. You may experience a different version of our sites based on feature testing, or view personalized content based on your visitor attributes. Adobe Target Privacy Policy
Google Analytics (Advertising)
We use Google Analytics (Advertising) to deploy digital advertising on sites supported by Google Analytics (Advertising). Ads are based on both Google Analytics (Advertising) data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that Google Analytics (Advertising) has collected from you. We use the data that we provide to Google Analytics (Advertising) to better customize your digital advertising experience and present you with more relevant ads. Google Analytics (Advertising) Privacy Policy
Trendkite
We use Trendkite to deploy digital advertising on sites supported by Trendkite. Ads are based on both Trendkite data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that Trendkite has collected from you. We use the data that we provide to Trendkite to better customize your digital advertising experience and present you with more relevant ads. Trendkite Privacy Policy
Hotjar
We use Hotjar to deploy digital advertising on sites supported by Hotjar. Ads are based on both Hotjar data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that Hotjar has collected from you. We use the data that we provide to Hotjar to better customize your digital advertising experience and present you with more relevant ads. Hotjar Privacy Policy
6 Sense
We use 6 Sense to deploy digital advertising on sites supported by 6 Sense. Ads are based on both 6 Sense data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that 6 Sense has collected from you. We use the data that we provide to 6 Sense to better customize your digital advertising experience and present you with more relevant ads. 6 Sense Privacy Policy
Terminus
We use Terminus to deploy digital advertising on sites supported by Terminus. Ads are based on both Terminus data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that Terminus has collected from you. We use the data that we provide to Terminus to better customize your digital advertising experience and present you with more relevant ads. Terminus Privacy Policy
StackAdapt
We use StackAdapt to deploy digital advertising on sites supported by StackAdapt. Ads are based on both StackAdapt data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that StackAdapt has collected from you. We use the data that we provide to StackAdapt to better customize your digital advertising experience and present you with more relevant ads. StackAdapt Privacy Policy
The Trade Desk
We use The Trade Desk to deploy digital advertising on sites supported by The Trade Desk. Ads are based on both The Trade Desk data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that The Trade Desk has collected from you. We use the data that we provide to The Trade Desk to better customize your digital advertising experience and present you with more relevant ads. The Trade Desk Privacy Policy
RollWorks
We use RollWorks to deploy digital advertising on sites supported by RollWorks. Ads are based on both RollWorks data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. This information may be combined with data that RollWorks has collected from you. We use the data that we provide to RollWorks to better customize your digital advertising experience and present you with more relevant ads. RollWorks Privacy Policy

Are you sure you want a less customized experience?

We can access your data only if you select "yes" for the categories on the previous screen. This lets us tailor our marketing so that it's more relevant for you. You can change your settings at any time by visiting our privacy statement

Your experience. Your choice.

We care about your privacy. The data we collect helps us understand how you use our products, what information you might be interested in, and what we can improve to make your engagement with Autodesk more rewarding.

May we collect and use your data to tailor your experience?

Explore the benefits of a customized experience by managing your privacy settings for this site or visit our Privacy Statement to learn more about your options.