Results 1 to 4 of 4

Thread: Rotating block jig in VB.NET

  1. #1
    100 Club mcoffman's Avatar
    Join Date
    2005-08
    Location
    Porland, OR
    Posts
    127

    Question Rotating block jig in VB.NET

    Greetings!

    I'm a VB.NET programmer and am just starting to delve into the AutoCAD API. I'm experimenting with Jigs and was wondering: Is there a way to insert a block using a Jig then rotate said block utilizing a jig to 'ghost' the rotation?

    Thanks!
    Michael

  2. #2
    Active Member Bobby C. Jones's Avatar
    Join Date
    2001-08
    Location
    Texas
    Posts
    62

    Default Re: Rotating block jig in VB.NET

    The short answer is yes. If you're looking for example code your best bet is to do a search on th forums. If that doesn't turn up what you need come back to this thread and we'll work something up.

  3. #3
    Woo! Hoo! my 1st post jason.lake's Avatar
    Join Date
    2009-06
    Posts
    1

    Post Re: Rotating block jig in VB.NET

    Ok. I was excited when I found this post a few days ago since I had spent a day looking and not finding much. Since then I have found a few posts on how to create a block rotation jig in C#, but nothing in VB, so I've learned how to translate (kind of).

    I came up with the following...

    Code:
    Class rotateBlockJig
        Inherits EntityJig
    
        Sub New(ByVal ent As Entity)
            'mybase.new must be called because the base class entity jig does not have an accesible sub new that can be accesses with no arguments
            MyBase.New(ent)
        End Sub
        Private lastMousePosition As Point3d = New Point3d()
        Property jiggedBlockReference() As BlockReference
            Get
                Return Me.Entity
            End Get
            Set(ByVal value As BlockReference)
    
            End Set
        End Property
        Property currentPosition() As Point3d
            Get
                Return jiggedBlockReference.position
            End Get
            Set(ByVal value As Point3d)
    
            End Set
        End Property
    
        Protected Overrides Function Sampler(ByVal prompts As Autodesk.AutoCAD.EditorInput.JigPrompts) As Autodesk.AutoCAD.EditorInput.SamplerStatus
    
            Dim jigOpt As JigPromptPointOptions = New JigPromptPointOptions("Select Rotation :")
            jigOpt.UserInputControls = UserInputControls.Accept3dCoordinates
            jigOpt.UserInputControls = UserInputControls.GovernedByOrthoMode
    
            Dim res As PromptPointResult = prompts.AcquirePoint(jigOpt)
    
            If res.Status <> PromptStatus.OK Then
                Return SamplerStatus.Cancel
            End If
    
            If (res.Value.IsEqualTo(currentPosition, New Tolerance(0.1, 0.1))) Then
                Return SamplerStatus.NoChange
            End If
    
            lastMousePosition = res.Value
    
            Return SamplerStatus.OK
    
        End Function
    
        Protected Overrides Function Update() As Boolean
    
            Dim oldPosition As Point2d = New Point2d(currentPosition.X, currentPosition.Y)
            Dim newPosition As Point2d = New Point2d(lastMousePosition.x, lastMousePosition.Y)
    
            jiggedBlockReference.Rotation = oldPosition.GetVectorTo(newPosition).Angle - Math.PI / 2
    
            'code for use with dynamic blocks
            For Each prop As DynamicBlockReferenceProperty In jiggedBlockReference.DynamicBlockReferencePropertyCollection
                If prop.PropertyName.ToUpper = "LENGTH" Then
                    prop.Value = oldPosition.GetDistanceTo(newPosition)
                End If
            Next
    
            Return True
        End Function
    End Class
    This works well except that I can't constrain the rotation with ORTHO. I've got the "jigOpt.UserInputControls = UserInputControls.GovernedByOrthoMode" line in there, but it's not working.

    To be frank I'm a newbie at .NET and programming in general. I've spent the last year learning and working with VBA and now we're moving to 64bit, so the .NET conversion was inevitable. I understand the basics of what's going on with the jig, but I just don't understand where the ORTHO comes into play.

    For us newbies any explanation would be greatly appreciated.

    Thanks,
    JL

  4. #4
    Active Member
    Join Date
    2008-08
    Posts
    55

    Wink Re: Rotating block jig in VB.NET

    This works well except that I can't constrain the rotation with ORTHO. I've got the "jigOpt.UserInputControls = UserInputControls.GovernedByOrthoMode" line in there, but it's not working.
    I too am having this problem. If anyone has any clues please help.

    I already know that eliminating a basepoint snap gets rid of the weird angle that gets applied when ortho is turned on, but I am jigging to make a custom line command. So that really isn't an option for me. I have noticed that the next time through the loop ortho doesn't have a problem. So my next try will be to artificially invoke the first run with a zero length line and see if that fixes it.

    Edit: polar is also out of wack just like ortho; when trying to jig for a point using a rubber band snap

    the more I think about it. The more certain I am the problem is in the ECS (entity coordinate system) within the update function. Anyone know how to modify the ecs of an entity.
    A jig is creating a temporary database of some kind; So, uh... not only do I want to modify something that doesn't really exist, but I want to modify read only properties in it also
    Last edited by howardjosh; 2009-08-22 at 02:10 AM.

Similar Threads

  1. Losing Dynamics after Rotating the Block
    By Zuke in forum Dynamic Blocks - Technical
    Replies: 8
    Last Post: 2008-01-17, 12:10 AM
  2. Rotating a block but not the text
    By Zuke in forum Dynamic Blocks - Technical
    Replies: 5
    Last Post: 2007-12-10, 01:16 PM
  3. Rotating attributes independently of a Block
    By whdjr in forum Dynamic Blocks - Technical
    Replies: 15
    Last Post: 2006-09-14, 02:38 PM
  4. Keep Attribute rotation at 0 when rotating a Block
    By tmouser in forum AutoCAD General
    Replies: 2
    Last Post: 2006-06-29, 02:16 PM
  5. Rotating a block
    By b_v_mc in forum AutoLISP
    Replies: 10
    Last Post: 2006-03-02, 06:06 PM

Posting Permissions

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