.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Drag and scale a block depends on cursor location
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hello,
I simplify the question. Let's say I want to insert block and if cursor is in negative coordinates block should be 2 times bigger,
other wise the same scale. At the same time when I drag the block Jig it should become bigger as well, in negative coordination.
Don't know how to do that. Any light or help would be appreciated. My real problem is how to drag and change the scale at the same time based on cursor location. Right now I am using point monitor to check the location.
Cheers and Merry Christmas
Janet.
Solved! Go to Solution.
Re: Drag and scale a block depends on cursor location
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Sounds like you need to implement a jig (e.g. DrawJig class).
Stephen Preston
Autodesk Developer Network
Re: Drag and scale a block depends on cursor location
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks Stephen,
I am going to try that. Happy Holidays.
Janet.
Re: Drag and scale a block depends on cursor location
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Stephen , I tried and it worked. Thanks.
I was trying to just drag the block and in the mean time tried to use transfomby scale matrix3d and it was not the proper way.
Happy holidays.
Re: Drag and scale a block depends on cursor location
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Try another way on your machine
Tested on attributed blocks (non-dynamic)
Imports System.Text
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Geometry
Namespace VBTemplate
Public Class BlockReactor
Implements Autodesk.AutoCAD.Runtime.IExtensionApplication
'
Private dm As DocumentCollection
Private doc As Document
Private db As Database
Private ed As Editor
Private counter As Integer
''' <summary>
''' Initializing the class members
''' </summary>
Public Sub MyInitialize()
dm = Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager
doc = dm.MdiActiveDocument
db = doc.Database
ed = doc.Editor
counter = 0
End Sub
''' <summary>
''' Method that will start this DLL
''' </summary>
Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Ini tialize
'Variables initializing
If doc Is Nothing Then
MyInitialize()
End If
Dim filt As SelectionFilter = New SelectionFilter(New TypedValue() {New TypedValue(0, "insert"), New TypedValue(66, 1)})
Dim psr As PromptSelectionResult = ed.SelectAll(filt)
If psr.Status = PromptStatus.OK Then
If psr.Value.Count > 0 Then
ed.WriteMessage(vbLf & "Selected attributed blocks: {0}", psr.Value.Count)
For Each item As ObjectId In psr.Value.GetObjectIds()
Using tr As Transaction = db.TransactionManager.StartTransaction()
Dim obj As DBObject = tr.GetObject(item, OpenMode.ForRead)
If TypeOf obj Is BlockReference Then
Dim bref As BlockReference = CType(tr.GetObject(item, OpenMode.ForRead), BlockReference)
AddHandler bref.Modified, AddressOf obj_Modified
End If
End Using
Next
End If
End If
AddHandler doc.BeginDocumentClose, AddressOf doc_BeginDocumentClose
ed.WriteMessage(vbLf + "Changed attributes may be stored in Database on close drawing" _
+ vbLf + "Initialization done")
End Sub
''' <summary>
''' Method that will start on closing document
''' </summary>
Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Ter minate
Dim filt As SelectionFilter = New SelectionFilter(New TypedValue() {New TypedValue(0, "insert"), New TypedValue(66, 1)})
Dim res As PromptSelectionResult = ed.SelectAll(filt)
Dim eids As ObjectId() = res.Value.GetObjectIds()
For Each eid As ObjectId In eids
Dim obj As Entity = DirectCast(eid.GetObject(OpenMode.ForRead, False), Entity)
If eid.ObjectClass = RXClass.GetClass(GetType(BlockReference)) Then
Dim bref As BlockReference = DirectCast(TryCast(obj, BlockReference), BlockReference)
RemoveHandler obj.Modified, AddressOf obj_Modified 'unregister event
End If
Next
RemoveHandler doc.BeginDocumentClose, AddressOf doc_BeginDocumentClose 'unregister event
End Sub
Friend Sub obj_Modified(ByVal sender As Object, ByVal e As EventArgs)
Dim bref As BlockReference = Nothing
bref = DirectCast(sender, BlockReference)
Dim p As Point3d = bref.Position
Dim hdl As String = bref.Handle.ToString
doc.SendStringToExecute("_SCALE " & "(handent " & Chr(34) & hdl & Chr(34) & ")" & vbCr & Chr(32) & p.X.ToString + "," & p.Y.ToString & Chr(32) & "2.0" & vbCr, False, False, False)
RemoveHandler bref.Modified, AddressOf obj_Modified
counter += 1
End Sub
Private Sub doc_BeginDocumentClose(ByVal sender As Object, ByVal e As DocumentBeginCloseEventArgs)
Autodesk.AutoCAD.ApplicationServices.Application.S howAlertDialog("Modified : " & counter.ToString & " blocks")
End Sub
End Class
End NameSpace
C6309D9E0751D165D0934D0621DFF27919
