Consulting

Page 1 of 2 1 2 LastLast
Results 1 to 20 of 25

Thread: Stretching Dimensions via VBA

  1. #1

    Angry Stretching Dimensions via VBA

    I'm trying to figure out how to "stretch" a dimension via Code. I've placed some objects and then dimensions. I want to be able to move those objects to a new location updating the dimensions as well. What happens is that the entire dimension moves not just the control pts @ the object. I've tried all sorts of selection set filter codes but no luck.

    fcode(0) = -4: ftype(0) = "<and"
            fcode(1) = -4: ftype(1) = "<or"
            fcode(2) = 0: ftype(2) = "INSERT" ' block I want to move
            fcode(3) = 0: ftype(3) = "Dimension" ' dimension(s) at the block location
            fcode(4) = -4: ftype(4) = "or>"
            fcode(5) = -4: ftype(5) = "<not"
            fcode(6) = 14: ftype(6) = vupperright ' don't move one side of a dimension
            fcode(7) = 13: ftype(7) = vupperleft ' don't move another side of a different dimension
            fcode(8) = -4: ftype(8) = "not>"
            fcode(9) = -4: ftype(9) = "and>"
    This selection set here gives me an error about invalid procedure call

    Here is the remaining code...if I just use the <or INSERT Dimension or> then
    everything moves including the line

    On Error Resume Next
              ThisDrawing.SelectionSets.Item("HandleSelection").Delete
            On Error GoTo 0
    Set objss = ThisDrawing.SelectionSets.Add("HandleSelection")
              objss.Select acSelectionSetCrossing, pt1, pt2, fcode, ftype
    For Each objSelection In objss
                objSelection.Move vOldPT, HandleLocPT
                objSelection.Update
                Next
    Any ideas, work arounds....

  2. #2
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Hi RickyD302,

    First:
    fcode(2) = 0: ftype(2) = "INSERT," ' block I want to move
    Add a comma after the INSERT, that may be what it is looking for.

    I am not sure what you are talking about on the dimensions. Could you zip a drawing with what you have and what you want? Also a dimension has properties that you can manipulate just like any other object. This may be a case of which property needs to be changed.

  3. #3

    moving block and dimension

    What I've done is create a application where a user builds his handle scheme via a VBA form. He then places that scheme in the drawing. The handles are dynamic blocks that are placed a calculated locations. I then dimension the "handle" locations. I'm wanting to allow the user to edit those locations later if need be. If the drawing changes by length or width then recalculations need to be done and then the handles need to move to the new locations. I've not be able to ps z e associate the dimension via VBA so I want to move the handles and have the dimension update. I can find the handle since it is a block.
    I've attached the drawing to reflect what I'm talking. I look forward to your ideas.

  4. #4

    getting the properties that need to be changed

    Yea Tommy,
    I think I need to get the right control points of the dimension to move but I can't seem to get my selection set correct. When I move pass
    fcode(0) = -4: ftype(0) = "<or"
            fcode(1) = 0: ftype(1) = "INSERT,"
            fcode(2) = 0: ftype(2) = "Dimension"
            fcode(3) = -4: ftype(3) = "or>"
    Then I start getting invalid procedure call.

    fcode(0) = -4: ftype(0) = "<and"
            fcode(1) = -4: ftype(1) = "<or"
            fcode(2) = 0: ftype(2) = "INSERT,"
            fcode(3) = 0: ftype(3) = "Dimension"
            fcode(4) = 100: ftype(4) = "Dimension"
            fcode(5) = 2: ftype(5) = "*D"
            fcode(6) = -4: ftype(6) = "or>"
            fcode(7) = -4: ftype(7) = "<not"
            fcode(8) = 13: ftype(8) = vupperleft
            fcode(9) = 14: ftype(9) = vupperright
            fcode(10) = -4: ftype(10) = "not>"
            fcode(11) = -4: ftype(11) = "and>"
    I know this isn't right but what I'm trying to do is grab the dimension then
    exclude the points I don't want to move. This is what I need to do correct?

  5. #5
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    After reviewing the drawing I would have to say no. You will need to select the dimensions and then change the properties.

    fcode(0) = 0: ftype(0) = "INSERT,Dimension"
    The above code will set the selection set to select INSERT and Dimension objects only. Now you will need to sort them according to the locations to the inserts I would think. Then move the ExtLine1Point or ExtLine2Point, then do an update for the dimension to update the information.

  6. #6

    how do I get the ExtLine1Point & ExtLine2Point

    are these exposed in VBA......do I search for them...could you provide a some code on what your thinking I'll change my code to reflect "insert,dimension" and see if I can get further. Thanks Tommy

  7. #7
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Much to my regret I am finding that when the dimension object is caputured it will not give up the ExtLine1Point and ExtLine2Point. I have now tried it 4 different ways, still no joy. I've tried selection sets and I've tried the loop throught the dimensions and I have even tried to use the handletoobject method. I may be able to get to it with a lisp and vba solution but am not sure at this point, I do know it can be done in lisp. A lot of things are exposed in lisp that are not exposed in vba for some reason. I will continue to try to find a solution.

  8. #8

    You the man

    I did find this that will expose the points

    I can't show the link because I dont' have enought post
    but here it is h t t p : / / discussion.autodesk.com/forums/message.jspa?messageID=5736419
    I'm not sure if this will do what I want ......

    but I'm getting a "Problem in loading application" error when I
    Function GetVl() As Object
        Application.LoadArx "VL.arx"
        Dim VLisp As Object
        Set VLisp = ThisDrawing.Application.GetInterfaceObject("VL.Application.17")
        Set GetVl = VLisp
    End Function
    Let me know what you think!

  9. #9
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    The link you posted was great! I can modify any dimension I pick however I want.

    But I have to pick it. Am still working on it though. I am severly stuck on the GetSubEntity I need this to get the OwnerId to get the block name that is for the dimension. Once I can get this it is mine

    Just a staus report.

    Anything yet at TekForum?

  10. #10

    no replies

    I've had some but they were the obvious ones like you need to move just the dimenion pts not the whole dimension. This is where I got hung up on was how to get around the getsubentity. There is a subentity class but it says its internal so....... If and when I get something I will pass it on for sure. thanks Tom.
    Another problem I'm having is that I can't load the VL.application.17
    I'm using 2009 mechanical and everything I've tried gives me "problem loading application" Any ideas on that one? I've actually posted this question in the Autodesk forums.

  11. #11
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    at this link:
    http://forums.augi.com/showthread.php?t=4704

    I found the attached file.

    Function GetVl() As Object
        Application.LoadArx "VL.arx"
       Dim VLisp As Object
        Set VLisp = ThisDrawing.Application.GetInterfaceObject("VL.Application.16")
        Set GetVl = VLisp
    End Function
    
    Sub ab()
        Dim al As Object
        ThisDrawing.SendCommand "(vl-load-com) "
        Set al = GetVl
    End Sub
    I got pasted all the error messages and I haven't tried to do anything else. The key is the .17 I had to change it to .16 I am using AutoCAD2007.

  12. #12

    NICE!

    I will look at this class.....compiled alright but now to figure out what I have.

  13. #13

    Interesting I had to leave it @ 16

    When I changed it to 17 I received an error but leaving @ 16 loaded alright.... Gotta love computers!

  14. #14

    Now that I can get to the endpoints

    Now that I can get to the end points How do I move them......Please understand that I am new to all this.

  15. #15
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    If you have the endpoints change to suite what you need.
    Keep in mind I don't know how you have selected the correct dimension to change.

  16. #16

    selecting the correct dimension

    I do this based on the point where the handle block is. I'm needing to move that block and control pt to a new location without moving the other control point of the dimension.

  17. #17
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Do you know the location or does it change for each block?
    Can I see the code you have so far for selecting the dimension?
    So far as the block it would be to change the insertion point to what you need, then you could add the difference to the adjustment to the dimension. Once you have the points you can check to see which on is in line with the block insertion point by checking the X and Y values. Then modifing the one that needs the change or vacation. LOL

  18. #18
    I have the where the handle was and where it will go so I have the neceassry information to move the handle to the correct location. What I'm having troubles with is stretching the dimension. When I selected the dimension and then do
    "object.move oldpt newpt" it would take the entire dimension with it. Now with the code you provided I'm trying to figure out what do do with it. I see that this code will give me the control points (DXF code 13 & 14) but this is where I start getting lost!

  19. #19
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Then why can't you move the block, delete the dimension and recreate it? I know that is not what you want to do but it may be faster and easier.

  20. #20
    I thought about that......I got everything to work by using the sendcommand. I create a small crossing window that picks up the block and dimensions.
    If I delete the dimensions then I'll have to have use select the dimension location when I re-dimension. I'm going to keep playing with trying to stretch the dimension just so I can say I figured it out but I was able to get my handle routince to work by using the sendcommand. Thank Tommy

Posting Permissions

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