TheSwamp
Code Red => VB(A) => Topic started by: DaveW 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.
-
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;
-
I think you may have to use boundingboxes to establish which viewport you are using.
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
-
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.
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
-
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 :)
-
Thank you very much. Your code looks promising.
Take care,
Dave
-
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
-
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.
-
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.
-
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?
-
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.
-
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.