Errors creating UCS objects

Errors creating UCS objects

Anonymous
Not applicable
1,078 Views
10 Replies
Message 1 of 11

Errors creating UCS objects

Anonymous
Not applicable
Hi all, congrats on making it to the end of another week of programming. I am trying to create new UCS objects and keep getting errors. I need to do some dimensioning in views perpendicular to the WCS. ie right, left, front... I kept getting an error when trying to create a rotated UCS, so I decided just to try moving the ucs and using the same vectors.. No luck there either... Set ucsObj = ThisDrawing.ActiveUCS' which is WCS origin(0) = 1 origin(1) = 0 origin(2) = 0 Set newUcsObj = ThisDrawing.UserCoordinateSystems.Add _ (origin, ucsObj.XVector, ucsObj.YVector, "testUCS") This gives me an error stating "The UCS x-axis point coincides the UCS origin" If I switch X and Y values above I get same error for y-axis. If I change the origin points to something like... origin(0) = 0 origin(1) = 5.5 origin(2) = 0 I get an error stating "The UCS x-axis and y-axis are not perpendicular"? What am I doing wrong? TFYT, Paul
0 Likes
1,079 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
Hi Paul There is a precision problem... James Belshan posted this a while ago (06/11/03): > Well... I wrote the function (Add_UCS_improved) I mentioned in my previous > post, and a test function to demonstrate it. > It solves the problem of the vectors having to be perfectly perpendicular > (by making its own perpendicular Y vector) > I have not thoroughly checked it, though, so if there are errors it could be > due to what Terence mentioned in his post. If that's the case, this could > still be used to make the ucs at the origin, without running into the > perpendicularity problem. > Good luck, check for word-wrap, hope this helps you out. > James [code] Sub test_Improved_UCS() ' Create a UCS named "New_UCS" in current drawing 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 UCS #1 origin(0) = 4#: origin(1) = 5#: origin(2) = 3# xAxisPnt(0) = 5#: xAxisPnt(1) = 5#: xAxisPnt(2) = 3# yAxisPnt(0) = 4.5: yAxisPnt(1) = 6.7: yAxisPnt(2) = 3# ' call the improved ADD function Set ucsObj = Add_UCS_improved(origin, xAxisPnt, yAxisPnt, "New_UCS") MsgBox ucsObj.Name & " has been added." & vbCrLf & _ "Origin: " & ucsObj.origin(0) & ", " & ucsObj.origin(1) _ & ", " & ucsObj.origin(2) & vbCrLf & _ "X Axis: " & ucsObj.XVector(0) & ", " & ucsObj.XVector(1) _ & ", " & ucsObj.XVector(2) & vbCrLf & _ "Y Axis: " & ucsObj.YVector(0) & ", " & ucsObj.YVector(1) _ & ", " & ucsObj.YVector(2), , "Add Example" ' Define the UCS #2 origin(0) = 0.1: origin(1) = 0.2: origin(2) = 0.3 xAxisPnt(0) = 0.25: xAxisPnt(1) = 0.1: xAxisPnt(2) = 0.15 yAxisPnt(0) = 0.13: yAxisPnt(1) = -0.06: yAxisPnt(2) = 0.2 ' Add the UCS to the UserCoordinatesSystems collection Set ucsObj = Nothing Set ucsObj = Add_UCS_improved(origin, xAxisPnt, yAxisPnt, "NewUCS#2") MsgBox ucsObj.Name & " has been added." & vbCrLf & _ "Origin: " & ucsObj.origin(0) & ", " & ucsObj.origin(1) _ & ", " & ucsObj.origin(2) & vbCrLf & _ "X Axis: " & ucsObj.XVector(0) & ", " & ucsObj.XVector(1) _ & ", " & ucsObj.XVector(2) & vbCrLf & _ "Y Axis: " & ucsObj.YVector(0) & ", " & ucsObj.YVector(1) _ & ", " & ucsObj.YVector(2), , "Add Example" End Sub Function Add_UCS_improved(origin() As Double, xAxisPnt() _ As Double, yAxisPnt() As Double, ucsName As String) As AcadUCS ' origin, xAxisPnt, and yAxisPnt must all be dimmed (0 to 2) Dim ucsObj As AcadUCS Dim xAxisVec(0 To 2) As Double Dim yAxisVec(0 To 2) As Double Dim perpYaxisPnt(0 To 2) As Double Dim xCy As Variant, perpYaxisVec As Variant xAxisVec(0) = xAxisPnt(0) - origin(0) xAxisVec(1) = xAxisPnt(1) - origin(1) xAxisVec(2) = xAxisPnt(2) - origin(2) yAxisVec(0) = yAxisPnt(0) - origin(0) yAxisVec(1) = yAxisPnt(1) - origin(1) yAxisVec(2) = yAxisPnt(2) - origin(2) xCy = Cross3D(xAxisVec, yAxisVec) perpYaxisVec = Cross3D(xCy, xAxisVec) perpYaxisPnt(0) = perpYaxisVec(0) + origin(0) perpYaxisPnt(1) = perpYaxisVec(1) + origin(1) perpYaxisPnt(2) = perpYaxisVec(2) + origin(2) Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(origin, xAxisPnt, _ perpYaxisPnt, ucsName) Set Add_UCS_improved = ucsObj End Function Function Cross3D(A As Variant, B As Variant) As Variant ' A and B must be dimensioned Double(0 to 2) Dim C(0 To 2) As Double C(0) = A(1) * B(2) - A(2) * B(1) C(1) = -(A(0) * B(2) - A(2) * B(0)) C(2) = A(0) * B(1) - A(1) * B(0) Cross3D = C End Function[/code] Cheers -- Juerg Menzi MENZI ENGINEERING GmbH, Switzerland http://www.menziengineering.ch
0 Likes
Message 3 of 11

Anonymous
Not applicable
Juerg, And James..Thanks..wish I had posted sooner..messed with it for a few days. Cheers, Paul "Jürg Menzi" wrote in message news:[email protected]... > Hi Paul > > There is a precision problem... > James Belshan posted this a while ago (06/11/03): > > > Well... I wrote the function (Add_UCS_improved) I mentioned in my previous > > post, and a test function to demonstrate it. > > It solves the problem of the vectors having to be perfectly perpendicular > > (by making its own perpendicular Y vector) > > > I have not thoroughly checked it, though, so if there are errors it could be > > due to what Terence mentioned in his post. If that's the case, this could > > still be used to make the ucs at the origin, without running into the > > perpendicularity problem. > > > Good luck, check for word-wrap, hope this helps you out. > > James > > [code] > Sub test_Improved_UCS() > > ' Create a UCS named "New_UCS" in current drawing > 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 UCS #1 > origin(0) = 4#: origin(1) = 5#: origin(2) = 3# > xAxisPnt(0) = 5#: xAxisPnt(1) = 5#: xAxisPnt(2) = 3# > yAxisPnt(0) = 4.5: yAxisPnt(1) = 6.7: yAxisPnt(2) = 3# > > ' call the improved ADD function > Set ucsObj = Add_UCS_improved(origin, xAxisPnt, yAxisPnt, "New_UCS") > MsgBox ucsObj.Name & " has been added." & vbCrLf & _ > "Origin: " & ucsObj.origin(0) & ", " & ucsObj.origin(1) _ > & ", " & ucsObj.origin(2) & vbCrLf & _ > "X Axis: " & ucsObj.XVector(0) & ", " & ucsObj.XVector(1) _ > & ", " & ucsObj.XVector(2) & vbCrLf & _ > "Y Axis: " & ucsObj.YVector(0) & ", " & ucsObj.YVector(1) _ > & ", " & ucsObj.YVector(2), , "Add Example" > > ' Define the UCS #2 > origin(0) = 0.1: origin(1) = 0.2: origin(2) = 0.3 > xAxisPnt(0) = 0.25: xAxisPnt(1) = 0.1: xAxisPnt(2) = 0.15 > yAxisPnt(0) = 0.13: yAxisPnt(1) = -0.06: yAxisPnt(2) = 0.2 > > ' Add the UCS to the UserCoordinatesSystems collection > Set ucsObj = Nothing > Set ucsObj = Add_UCS_improved(origin, xAxisPnt, yAxisPnt, "NewUCS#2") > MsgBox ucsObj.Name & " has been added." & vbCrLf & _ > "Origin: " & ucsObj.origin(0) & ", " & ucsObj.origin(1) _ > & ", " & ucsObj.origin(2) & vbCrLf & _ > "X Axis: " & ucsObj.XVector(0) & ", " & ucsObj.XVector(1) _ > & ", " & ucsObj.XVector(2) & vbCrLf & _ > "Y Axis: " & ucsObj.YVector(0) & ", " & ucsObj.YVector(1) _ > & ", " & ucsObj.YVector(2), , "Add Example" > > End Sub > > > Function Add_UCS_improved(origin() As Double, xAxisPnt() _ > As Double, yAxisPnt() As Double, ucsName As String) As AcadUCS > ' origin, xAxisPnt, and yAxisPnt must all be dimmed (0 to 2) > > Dim ucsObj As AcadUCS > Dim xAxisVec(0 To 2) As Double > Dim yAxisVec(0 To 2) As Double > Dim perpYaxisPnt(0 To 2) As Double > Dim xCy As Variant, perpYaxisVec As Variant > > xAxisVec(0) = xAxisPnt(0) - origin(0) > xAxisVec(1) = xAxisPnt(1) - origin(1) > xAxisVec(2) = xAxisPnt(2) - origin(2) > yAxisVec(0) = yAxisPnt(0) - origin(0) > yAxisVec(1) = yAxisPnt(1) - origin(1) > yAxisVec(2) = yAxisPnt(2) - origin(2) > > xCy = Cross3D(xAxisVec, yAxisVec) > perpYaxisVec = Cross3D(xCy, xAxisVec) > > perpYaxisPnt(0) = perpYaxisVec(0) + origin(0) > perpYaxisPnt(1) = perpYaxisVec(1) + origin(1) > perpYaxisPnt(2) = perpYaxisVec(2) + origin(2) > > Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(origin, xAxisPnt, _ > perpYaxisPnt, ucsName) > Set Add_UCS_improved = ucsObj > > End Function > > Function Cross3D(A As Variant, B As Variant) As Variant > ' A and B must be dimensioned Double(0 to 2) > Dim C(0 To 2) As Double > C(0) = A(1) * B(2) - A(2) * B(1) > C(1) = -(A(0) * B(2) - A(2) * B(0)) > C(2) = A(0) * B(1) - A(1) * B(0) > Cross3D = C > End Function[/code] > > Cheers > -- > Juerg Menzi > MENZI ENGINEERING GmbH, Switzerland > http://www.menziengineering.ch
0 Likes
Message 4 of 11

Anonymous
Not applicable
Welcome...8-) Cheers -- Juerg Menzi MENZI ENGINEERING GmbH, Switzerland http://www.menziengineering.ch
0 Likes
Message 5 of 11

Anonymous
Not applicable
Paul, Please write back whether this routine actually is an improvement over the normal AddUCS method. It seemed to be helpful (create UCS's with inputs that would choke the normal AddUCS method) when I wrote it, but it has gotten mixed reviews from different people who tried it. James
0 Likes
Message 6 of 11

Anonymous
Not applicable
James, It still doesn't allow me to drive the UCS to any exact location in 3D space. My program creates a 3D model and exact cutlist from 2d ADT drawings created by operators. See pics.. The cut list is then sent to an assembly line(engineers are still building it) which is fully automated. Five machines in line which will produce any of the twenty different log types in a house. I started by dividing up all the solid box objects(seiso..pic) into individual logs(solid box objs) but large drawings got a bit overwhelming for operators. The company also didn't want their operators to learn any 3D for editing. I now use Dims to divide up logs(box objects). Dim extension lines are log separators.( front elev pic). User can now edit by just using a version of the stretch command that allows them to grab common extension lines and visually change logs lengths by watching Dim values change. Problem is driving the UCS to each elevation in drawing. Sample I sent is a basic home but complex houses with multiple stories and gables are common. I am now using SendCommand to move and rotate UCS around proper axis. Lots to go wrong this way though. Some homes have upwards of 1200 logs. I'm thinking if I'm going to be scripting this part of the code with the SendCommand might as well use Lisp to produces Dims. Hope this made some sense. It's early Sunday morning. Any thoughts if anyone made it this far? Thanks for your time, Paul "James Belshan" wrote in message news:411e8ad9$1_1@newsprd01... > Paul, > Please write back whether this routine actually is an improvement over the > normal AddUCS method. It seemed to be helpful (create UCS's wit h inputs > that would choke the normal AddUCS method) when I wrote it, but it has > gotten mixed reviews from different people who tried it. > > James > > >
0 Likes
Message 7 of 11

Anonymous
Not applicable
btw..the Pre-Suf fix's on the dims are L left, M male, S standard, D door, ect.... The sample front elev I sent has a few RS right standard cuts, that should be RD right door....in case you were wondering... Cheers, Paul "Paul Richardson" wrote in message news:411f3621_1@newsprd01... > James, > > It still doesn't allow me to drive the UCS to any exact location in 3D > space. > > My program creates a 3D model and exact cutlist from 2d ADT drawings created > by operators. See pics.. The cut list is then sent to an assembly > line(engineers are still building it) which is fully automated. Five > machines in line which will produce any of the twenty different log types in > a house. > > I started by dividing up all the solid box objects(seiso..pic) into > individual logs(solid box objs) but large drawings got a bit overwhelming > for operators. The company also didn't want their operators to learn any 3D > for editing. > > I now use Dims to divide up logs(box objects). Dim extension lines are log > separators.( front elev pic). User can now edit by just using a version of > the stretch command that allows them to grab common extension lines and > visually change logs lengths by watching Dim values change. > > Problem is driving the UCS to each elevation in drawing. Sample I sent is a > basic home but complex houses with multiple stories and gables are common. > > I am now using SendCommand to move and rotate UCS around proper axis. Lots > to go wrong this way though. Some homes have upwards of 1200 logs. > > I'm thinking if I'm going to be scripting this part of the code with the > SendCommand might as well use Lisp to produces Dims. > > Hope this made some sense. It's early Sunday morning. Any thoughts if anyone > made it this far? > > Thanks for your time, > > Paul > > > "James Belshan" wrote in message > news:411e8ad9$1_1@newsprd01... > > Paul, > > Please write back whether this routine actually is an improvement over the > > normal AddUCS method. It seemed to be helpful (create UCS's wit > h inputs > > that would choke the normal AddUCS method) when I wrote it, but it has > > gotten mixed reviews from different people who tried it. > > > > James > > > > > > > > >
0 Likes
Message 8 of 11

Anonymous
Not applicable
Hi Paul > It still doesn't allow me to drive the UCS to any exact location in 3D > space. Another workaround: Create the UCS at 0,0,0 origin and after that change the UCS origin coordinates to the current point. Cheers -- Juerg Menzi MENZI ENGINEERING GmbH, Switzerland http://www.menziengineering.ch
0 Likes
Message 9 of 11

Anonymous
Not applicable
> It still doesn't allow me to drive the UCS to any exact location in 3D space. > Paul, I'm using tunnel-vision to ignore the rest of your (interesting) problem, and just focus on the "moving the UCS" part.... only so many hours in a day. I tweaked my code samples to let me pick 3 points and use them to move the current UCS to those 3 points. I changed the function to use Variants for parameters, as a quick way to make it interface better with the GetPoint calls. Other than that, the Functions are the same. I created a little 60x40 log cabin and was able to pop the active UCS anywhere on it that I wanted to. See attached pic for one UCS location. Is this still not accomplishing what you need? HTH, James [code] Sub test_Improved_UCS() ' Create a UCS named "New_UCS" in current drawing Dim ucsObj As AcadUCS Dim origin As Variant, xAxisPnt As Variant, yAxisPnt As Variant ' Define the UCS #1 origin = ThisDrawing.Utility.GetPoint(, "Enter origin:") xAxisPnt = ThisDrawing.Utility.GetPoint(ThisDrawing.Utility.TranslateCoordinates(origin , acWorld, acUCS, False), "Enter x-Axis Point:") yAxisPnt = ThisDrawing.Utility.GetPoint(ThisDrawing.Utility.TranslateCoordinates(origin , acWorld, acUCS, False), "Enter point in X-Y Plane:") ' call the improved ADD function Set ucsObj = Add_UCS_improved(origin, xAxisPnt, yAxisPnt, "New_UCS") ThisDrawing.ActiveUCS = ucsObj End Sub Function Add_UCS_improved(origin As Variant, xAxisPnt _ As Variant, yAxisPnt As Variant, ucsName As String) As AcadUCS ' origin, xAxisPnt, and yAxisPnt must all contain Doubles dimmed (0 to 2) Dim ucsObj As AcadUCS Dim xAxisVec(0 To 2) As Double Dim yAxisVec(0 To 2) As Double Dim perpYaxisPnt(0 To 2) As Double Dim xCy As Variant, perpYaxisVec As Variant xAxisVec(0) = xAxisPnt(0) - origin(0) xAxisVec(1) = xAxisPnt(1) - origin(1) xAxisVec(2) = xAxisPnt(2) - origin(2) yAxisVec(0) = yAxisPnt(0) - origin(0) yAxisVec(1) = yAxisPnt(1) - origin(1) yAxisVec(2) = yAxisPnt(2) - origin(2) xCy = Cross3D(xAxisVec, yAxisVec) perpYaxisVec = Cross3D(xCy, xAxisVec) perpYaxisPnt(0) = perpYaxisVec(0) + origin(0) perpYaxisPnt(1) = perpYaxisVec(1) + origin(1) perpYaxisPnt(2) = perpYaxisVec(2) + origin(2) Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(origin, xAxisPnt, perpYaxisPnt, ucsName) Set Add_UCS_improved = ucsObj End Function Function Cross3D(A As Variant, B As Variant) As Variant ' A and B must be dimensioned Double(0 to 2) Dim C(0 To 2) As Double C(0) = A(1) * B(2) - A(2) * B(1) C(1) = -(A(0) * B(2) - A(2) * B(0)) C(2) = A(0) * B(1) - A(1) * B(0) Cross3D = C End Function [/code]
0 Likes
Message 10 of 11

Anonymous
Not applicable
James, Thanks for your help...works great. Sorry for the rambling this morning, was mostly talking to myself..didn't realize how long it was till I read after posting. Even I didn't want to read it...Ha.. Cheers, Paul "James Belshan" wrote in message news:411ff2c3_3@newsprd01... > > It still doesn't allow me to drive the UCS to any exact location in 3D > space. > > > > > Paul, > I'm using tunnel-vision to ignore the rest of your (interesting) problem, > and just focus on the "moving the UCS" part.... only so many hours in a day. > I tweaked my code samples to let me pick 3 points and use them to move the > current UCS to those 3 points. I changed the function to use Variants for > parameters, as a quick way to make it interface better with the GetPoint > calls. Other than that, the Functions are the same. > > I created a little 60x40 log cabin and was able to pop the active UCS > anywhere on it that I wanted to. See attached pic for one UCS location. > > Is this still not accomplishing what you need? > HTH, > > James > > > [code] > Sub test_Improved_UCS() > > ' Create a UCS named "New_UCS" in current drawing > Dim ucsObj As AcadUCS > Dim origin As Variant, xAxisPnt As Variant, yAxisPnt As Variant > > ' Define the UCS #1 > origin = ThisDrawing.Utility.GetPoint(, "Enter origin:") > xAxisPnt = > ThisDrawing.Utility.GetPoint(ThisDrawing.Utility.TranslateCoordinates(origin > , acWorld, acUCS, False), "Enter x-Axis Point:") > yAxisPnt = > ThisDrawing.Utility.GetPoint(ThisDrawing.Utility.TranslateCoordinates(origin > , acWorld, acUCS, False), "Enter point in X-Y Plane:") > > ' call the improved ADD function > Set ucsObj = Add_UCS_improved(origin, xAxisPnt, yAxisPnt, "New_UCS") > > ThisDrawing.ActiveUCS = ucsObj > > End Sub > > > Function Add_UCS_improved(origin As Variant, xAxisPnt _ > As Variant, yAxisPnt As Variant, ucsName As String) As AcadUCS > ' origin, xAxisPnt, and yAxisPnt must all contain Doubles dimmed (0 to 2) > > Dim ucsObj As AcadUCS > Dim xAxisVec(0 To 2) As Double > Dim yAxisVec(0 To 2) As Double > Dim perpYaxisPnt(0 To 2) As Double > Dim xCy As Variant, perpYaxisVec As Variant > > xAxisVec(0) = xAxisPnt(0) - origin(0) > xAxisVec(1) = xAxisPnt(1) - origin(1) > xAxisVec(2) = xAxisPnt(2) - origin(2) > yAxisVec(0) = yAxisPnt(0) - origin(0) > yAxisVec(1) = yAxisPnt(1) - origin(1) > yAxisVec(2) = yAxisPnt(2) - origin(2) > > xCy = Cross3D(xAxisVec, yAxisVec) > perpYaxisVec = Cross3D(xCy, xAxisVec) > > perpYaxisPnt(0) = perpYaxisVec(0) + origin(0) > perpYaxisPnt(1) = perpYaxisVec(1) + origin(1) > perpYaxisPnt(2) = perpYaxisVec(2) + origin(2) > > Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(origin, xAxisPnt, > perpYaxisPnt, ucsName) > Set Add_UCS_improved = ucsObj > > End Function > > Function Cross3D(A As Variant, B As Variant) As Variant > ' A and B must be dimensioned Double(0 to 2) > Dim C(0 To 2) As Double > C(0) = A(1) * B(2) - A(2) * B(1) > C(1) = -(A(0) * B(2) - A(2) * B(0)) > C(2) = A(0) * B(1) - A(1) * B(0) > Cross3D = C > End Function > [/code] > > > >
0 Likes
Message 11 of 11

Anonymous
Not applicable
> Sorry for the rambling this morning, > was mostly talking to myself..didn't realize how long it was till I read > after posting. Even I didn't want to read it...Ha.. > No apology necessary. I just meant that I couldn't help you with the other parts of your question (Lisp vs VBA, etc). I could only tackle the one point, the UCS issue, and leave the other parts up to others. Good luck, James
0 Likes