Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lower left origin 1

Status
Not open for further replies.

Andylaug

Industrial
Apr 16, 2002
13
0
0
US
I'm looking for a simple code that will locate the origin of a window selected object at the lower left so that I can quickly diminsion that selection using the qdim ordinate method. I am wasting too much time creating this origin manually and would prefer to include it in the code for the button I've created for qdim (ordinate). Any suggestions?
 
Replies continue below

Recommended for you

I am not quite sure what you mean. Are you picking a bunch of stuff in a window, and you only want the lower left corner of some entity in the selection? I hope I am clear on this.

BU
 
What I'm trying to do is dimension parts using the ordinate method. In order to do that, I need to establish o,o in the lower left corner of the part so that my ordinate dims start from that corner. But sometime there isn't a convenient corner in the lower left (ie. a filleted corner) and I have to project the theoretical corner in order to establish 0,0. What I'm looking for is a routine that will find the origin of a selection set based on it's geometry and reset the origin to that point automatically.
 
What I'm looking for is code that will allow me to select the object to be dimensioned with a pick box and it will find the lower left x,y,z coordinate by tracking the extreme edges to a theoretical intersection, set the origin to 0,0,0 at that point, and then dimension the part using the qdim ordinate method.

My objective is to minimize the steps of dimensioning by assigning this code to a button and then just window select each solviewed part on a drawing and thereby increasing the speed of our draftsmen.

I have already assigned code to accomplish everything except finding the lower left origin automatically. and it's this step I wish to make transparent as well.
 
Dear Andylaug,
I have written a VBA code for your problem as follow:


Option Explicit
Sub SetOrigin()
Dim SOss As AcadSelectionSet
Dim SOobj As AcadEntity
Dim SOXMin As Double
Dim SOYMin As Double
Dim Minpt As Variant, Maxpt As Variant
Dim SOorig(0 To 2) As Double
Dim xAxis(0 To 2) As Double
Dim yAxis(0 To 2) As Double
Dim newUCS As AcadUCS

Randomize Timer
Set SOss = ThisDrawing.SelectionSets.Add(Rnd(Timer))
SOss.SelectOnScreen
ThisDrawing.SendCommand "UCS W "
SOss.Item(0).GetBoundingBox Minpt, Maxpt
SOXMin = Minpt(0)
SOYMin = Minpt(1)
For Each SOobj In SOss
SOobj.GetBoundingBox Minpt, Maxpt
If SOXMin > Minpt(0) Then
SOXMin = Minpt(0)
End If
If SOYMin > Minpt(1) Then
SOYMin = Minpt(1)
End If
Next SOobj
SOorig(0) = SOXMin
SOorig(1) = SOYMin
SOorig(2) = Minpt(2)
xAxis(0) = SOXMin + 1
xAxis(1) = SOYMin
xAxis(2) = Minpt(2)
yAxis(0) = SOXMin
yAxis(1) = SOYMin + 1
yAxis(2) = Minpt(2)
Set newUCS = ThisDrawing. _
UserCoordinateSystems.Add _
(SOorig, xAxis, yAxis, "0")
ThisDrawing.ActiveUCS = newUCS
End Sub


You can copy and paste the code into a VBA module an just run the SetOrigin subroutine. The routine requests you to select some objects and it sets the UCS on the lower left corner of selected objects.
The subroutine can be run using a toolbutton.
:)
Farzad
 
Status
Not open for further replies.
Back
Top