21 | 08 | 2017

Set UCS

When inserting multiple blocks or when placing 3d dimensions it is useful to rotate the UCS to the desired coordinates. The code below shows how to create new pre-defined UCS coordinates and how to call them.

Sub SetUCS()


'****************************************
'*** Code from VisibleVisual.com ********
'****************************************

Dim ucsObj As AcadUCS
Dim origin(0 To 2) As Double
Dim xAxisPnt(0 To 2) As Double
Dim yAxisPnt(0 To 2) As Double

'Define the first UCS coordinates
origin(0) = 0: origin(1) = 0: origin(2) = 0
xAxisPnt(0) = 0: xAxisPnt(1) = 0: xAxisPnt(2) = 1
yAxisPnt(0) = 1: yAxisPnt(1) = 0: yAxisPnt(2) = 0

' Add the UCS
Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(origin, xAxisPnt, yAxisPnt, "ucs1")

'Define the second UCS coordinates
origin(0) = 0: origin(1) = 0: origin(2) = 0
xAxisPnt(0) = 0: xAxisPnt(1) = 0: xAxisPnt(2) = 1
yAxisPnt(0) = 0: yAxisPnt(1) = 1: yAxisPnt(2) = 0

Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(origin, xAxisPnt, yAxisPnt, "ucs2")

'Define the thirth UCS coordinates
origin(0) = 0: origin(1) = 0: origin(2) = 0
xAxisPnt(0) = -1: xAxisPnt(1) = 0: xAxisPnt(2) = 0
yAxisPnt(0) = 0: yAxisPnt(1) = 0: yAxisPnt(2) = 1

Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(origin, xAxisPnt, yAxisPnt, "ucs3")

'Define the fourth UCS coordinates
origin(0) = 0: origin(1) = 0: origin(2) = 0
xAxisPnt(0) = 1: xAxisPnt(1) = 0: xAxisPnt(2) = 0
yAxisPnt(0) = 0: yAxisPnt(1) = 1: yAxisPnt(2) = 0

Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(origin, xAxisPnt, yAxisPnt, "world")

'etc,etc.........
End Sub

This is just one same you can play around with the settings to create the desired coordinates.

To call the pre-defined ucs by name use the following code:

Set ucsobject = ThisDrawing.UserCoordinateSystems.Item("ucs1")
ThisDrawing.ActiveUCS = ucsobject

 

 'Sample of the UCS created in the code above'


 

'Defined UCS coordinates arealso available at the UCSII toolbar'


Login

Sign up now and upload your code to the website.

Help us to continue.....
Statistics
Articles View Hits
2330630
Latest Articles