Author Topic: Automatically adding dimensions in paperspace.  (Read 4301 times)

0 Members and 1 Guest are viewing this topic.

DaveW

  • Guest
Automatically adding dimensions in paperspace.
« on: April 18, 2006, 09:17:52 AM »
Hi All,

I am looking to create a routine that can automatically dimension the 3D solids displayed in viewports.

Before I can begin I need to have some understanding of how you know the correlation between the relative coordinates in paperspace above a viewport and the real coordinates in modelspace.

Any suggestions, code, questions for me to clarify, etc. are welcome.

FYI. I noticed that the Express Tools, Layout Tools, Change Space will carry xdata with the objects transferred from modelspace to paperspace. This is interesting, as it can be used to create objects in paperspace that can be accessible to the end user for ballooning. You should also note that this utility that Autodesk made clearly shows that they understand and have the code to find the equivalent position in paperspace.

Thanks,

David Wishengrad
MillLister, Inc.

Shinyhead

  • Guest
Re: Automatically adding dimensions in paperspace.
« Reply #1 on: April 18, 2006, 09:23:48 AM »
cant you just issue the PS command in a macro with the dim command following? make sure you dimassoc is set properly and your good to go. Or are you looking for a "dim this object" button?

I'm still trying to get the following macro to work :wink:

^C^C_drawitall;dimitall;publishall;script;pay_me_now.scr;

Bryco

  • Water Moccasin
  • Posts: 1882
Re: Automatically adding dimensions in paperspace.
« Reply #2 on: April 18, 2006, 01:21:02 PM »
I think you may have to use  boundingboxes to establish which viewport you are using.

Code: [Select]
Public Sub ModeltoPaperSpacePoint()

    Dim vp As AcadPViewport, Ent As AcadEntity, VarPick
    Dim util As AcadUtility, M1, P1
    Dim i As Integer, dblScale As Double
    Dim VpCol As New Collection
    Dim PSpt As AcadPoint, MSpt As AcadPoint
   
    Set util = ThisDrawing.Utility
    If ThisDrawing.ActiveSpace = acModelSpace Then
        MsgBox "Command not allowed unless TILEMODE is set to 0"
        Exit Sub
    End If
    For Each Ent In ThisDrawing.PaperSpace
        If TypeOf Ent Is AcadPViewport Then
            i = i + 1
            VpCol.Add Ent
        End If
    Next
    If i = 1 Then
        MsgBox "Please add a viewport"
        Exit Sub
    End If
     'Debug.Print i
    If ThisDrawing.MSpace = False Then
        If i > 2 Then
            util.GetEntity Ent, VarPick, "Pick a viewport:"
            If TypeOf Ent Is AcadPViewport Then
                Set vp = Ent
            Else
                Exit Sub
            End If
         Else
            Set vp = VpCol(2)
        End If
        vp.Display True
        ThisDrawing.MSpace = True
        ThisDrawing.ActivePViewport = vp
    Else
        Set vp = ThisDrawing.ActivePViewport
    End If
    vp.DisplayLocked = True
 
    M1 = util.GetPoint(, "Pick a point:")
    Set MSpt = ThisDrawing.ModelSpace.AddPoint(M1)
    MSpt.Color = acBlue

   P1 = util.TranslateCoordinates(M1, acWorld, acDisplayDCS, False)
   P1 = util.TranslateCoordinates(P1, acDisplayDCS, acPaperSpaceDCS, False)
    ThisDrawing.MSpace = False
    Set PSpt = ThisDrawing.PaperSpace.AddPoint(P1)
    PSpt.Color = acGreen
    Set vp = Nothing
   
End Sub

Public Sub PapertoModelSpacePoint()

    Dim Ent As AcadEntity, VarPick
    Dim util As AcadUtility, M1, P1
    Dim PSpt As AcadPoint, MSpt As AcadPoint

    Set util = ThisDrawing.Utility
    ThisDrawing.ActiveSpace = acPaperSpace
    ThisDrawing.MSpace = False
    P1 = util.GetPoint(, "Pick a point:")
    Set PSpt = ThisDrawing.PaperSpace.AddPoint(P1)
    PSpt.Color = acGreen
    P1 = util.TranslateCoordinates(P1, acPaperSpaceDCS, acDisplayDCS, False)
    M1 = util.TranslateCoordinates(P1, acDisplayDCS, acWorld, False)
   
    Set MSpt = ThisDrawing.ModelSpace.AddPoint(M1)
    MSpt.Color = acBlue
   
End Sub

Bryco

  • Water Moccasin
  • Posts: 1882
Re: Automatically adding dimensions in paperspace.
« Reply #3 on: April 18, 2006, 05:55:29 PM »
This is a little better for when the viewport has a twist. 
There is no easy way to get  the  ucs associated with a viewport,
so the easy way is to set the activeviewport. This updates the Ucs
before the translations.
Code: [Select]
Public Sub PapertoModelSpacePoint()

    Dim Pv As AcadPViewport, Ent As AcadEntity, VarPick
    Dim util As AcadUtility
    Dim PSpt As AcadPoint, MSpt As AcadPoint
    Dim M1, P1, Orig
    Set util = ThisDrawing.Utility
    ThisDrawing.ActiveSpace = acPaperSpace
    ThisDrawing.MSpace = False
    P1 = util.GetPoint(, "Pick a point:")
    Set PSpt = ThisDrawing.PaperSpace.AddPoint(P1)
    PSpt.Color = acGreen
    Set Pv = EntSel
    ThisDrawing.MSpace = True
    ThisDrawing.ActivePViewport = Pv
    P1 = util.TranslateCoordinates(P1, acPaperSpaceDCS, acDisplayDCS, False)
    M1 = util.TranslateCoordinates(P1, acDisplayDCS, acWorld, False)
    Set MSpt = ThisDrawing.ModelSpace.AddPoint(M1)
    MSpt.Color = acBlue
    ThisDrawing.ActiveSpace = acPaperSpace
   
End Sub

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Automatically adding dimensions in paperspace.
« Reply #4 on: April 18, 2006, 06:03:50 PM »
This is a difficult one David, while you can get a point from mspace to pspace (Bryco's an old hand at this ;) ) I've found that with 3d solids, having topology is not enough.
If you can store your objects in some format in a file and model from that file you have everything you need to dimension your object in any space, you could use Bryco's code to get your initial 'start' or insert point.

Not easy but do-able :)
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

DaveW

  • Guest
Re: Automatically adding dimensions in paperspace.
« Reply #5 on: April 19, 2006, 04:25:27 PM »
Thank you very much. Your code looks promising.

Take care,

Dave

DaveW

  • Guest
Re: Automatically adding dimensions in paperspace.
« Reply #6 on: April 30, 2006, 02:42:21 PM »
Hey Guys,

Thanks for that code. I really want to mess around with that stuff, but I have been sidetracked converting solids from SAT files created by Rhino to ACAD solids. All of their entities in the solid are spines and we are trying to get this out to CNC where it all has to be lines, arcs, circles and Plines. What a mess, but I am almost done. I think I will port my grid to Rhino next and add feature recognition to that build after.

anyway.... I need to do this work for a company interested in  my software and I had not had a chance to work with the code above, but I will. Thanks a bunch,

Dave

DaveW

  • Guest
Re: Automatically adding dimensions in paperspace.
« Reply #7 on: June 07, 2006, 09:48:26 AM »
My code above uses the location of the points as the starting point for all the leaders and the location the user chooses to stack the text data.

Is there a way that the code could allow a visible view of the leader lines and the text for the balloons to be visible and update according to the placement of the cross hairs, so that the user can see and adjust the position of the text before committing to it?

Any help is appreciated. I have never seen any VB code do this before and so I have no idea if it is even possible through vb.

I am looking for that drag effect, but cannot find anyone or anything that does it in VB. I will see if anyone created an arx that I can access from my VB code in the meantime.

Thanks.
« Last Edit: June 07, 2006, 04:52:17 PM by DaveW »

DaveW

  • Guest
Re: Automatically adding dimensions in paperspace.
« Reply #8 on: June 10, 2006, 01:23:48 PM »
Ok Guys,

Again, THANK YOU VERY, VERY MUCH!!!!!!!!! :-) :-) :-) :-) :-) :-)

I made many, many changes to the code above, but it is great starting point for anyone who wants to get started doing something like this.

Here is what the completed utility does (10 meg avi encoded with windows media9 codec):

http://SmartLister.com/Files/Balloon1.avi

The video quality is fair. The leader lines only appear dashed in the video.

If anyone needs some help with any of routines, please just ask.
« Last Edit: June 10, 2006, 01:26:49 PM by DaveW »

Jim Yadon

  • Guest
Re: Automatically adding dimensions in paperspace.
« Reply #9 on: June 10, 2006, 01:33:47 PM »
Looks nice Dave. So when you were doing this, did you come up with the means to provide associative dimensions programmitcally from paper space to your model?

DaveW

  • Guest
Re: Automatically adding dimensions in paperspace.
« Reply #10 on: June 10, 2006, 01:42:04 PM »
Looks nice Dave. So when you were doing this, did you come up with the means to provide associative dimensions programmitcally from paper space to your model?


Thanks.

I have not gotten that far yet. This code took a long week and many headaces. I am not even a programmer.

I do have a much better understanding of converting the points from PS to MS and back.

The auto dimensioning will need that, but I may have to introduce a 2D projection and dim that and then delete it. I am still thinking on the concepts to use.

Bryco

  • Water Moccasin
  • Posts: 1882
Re: Automatically adding dimensions in paperspace.
« Reply #11 on: June 10, 2006, 03:21:50 PM »
Well done Dave
I wish I could say the hard part was done, but from now on you'll probably be doing a fair bit of research.