Creating UCS from line

Creating UCS from line

Jan-Brauer
Participant Participant
782 Views
2 Replies
Message 1 of 3

Creating UCS from line

Jan-Brauer
Participant
Participant

 

Can someone help me to create a UCS from a given line (should ultimately only use the x-direction so it is subordinate to how it is twisted around the x-axis.)

 

I have a problem switching to  a new UCS.

 

I have a given line, for it I find the starting point and the end point,

then I find a point perpendicular to the line from the starting point,

I have tried 2 methods:

    the first was a vector calculation in vba,

    the second used thisdrawing.utilitu.polarpunkt.

 

Then i used thisdrawing.ucs.add…..

 

With both calculations, AutoCAD came up with an error that the 3 points do not form a right angle.

 

I have tried to calculate both as points and as vectors

 

I have then had the program draw lines between the points.

It is now possible to switch UCS from the command line by pointing to the 3 points.

 

I therefore tried to use Sendcommand.

There is no error using this metode, but the generated UCS is completely wrong.

 

What do i do wrong 😞

 

0 Likes
783 Views
2 Replies
Replies (2)
Message 2 of 3

Ed__Jobe
Mentor
Mentor

Show your code so we can help you.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 3

Ray-Sync
Advocate
Advocate

I use this:

Sub coor_relat()

Dim myucs As AcadUCS
Dim pt As Variant, pt1 As Variant, pt2 As Variant
Dim l As AcadLine
Dim pi As Double

pi = 4 * Atn(1)

pt = ThisDrawing.Utility.GetPoint(, "clic 1 point")
pt1 = ThisDrawing.Utility.GetPoint(, "clic 2 point")
Set l = ThisDrawing.ModelSpace.AddLine(pt, pt1)

pt2 = ThisDrawing.Utility.PolarPoint(pt, l.Angle + (pi / 2), 1)

Set myucs = ThisDrawing.UserCoordinateSystems.Add(pt, pt1, pt2, "UCS1")
ThisDrawing.ActiveUCS = myucs
ThisDrawing.ActiveViewport.UCSIconOn = True
ThisDrawing.ActiveViewport.UCSIconAtOrigin = True
ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport

l.Delete

End Sub
jefferson
0 Likes