Author Topic: 3d arc, how to do it?  (Read 2530 times)

0 Members and 1 Guest are viewing this topic.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
3d arc, how to do it?
« on: April 24, 2006, 04:15:30 PM »
OK, i was asked to draw up a typical substation in 3d.  NO problem.  all the bus work is done, the transitions, circuit breakers, etc.  My question is how do I draw the soft connectios between the switchs and the circuit breakers in 3d?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Lin-Z

  • Guest
Re: 3d arc, how to do it?
« Reply #1 on: April 24, 2006, 05:01:57 PM »
I haven't really played with doing 3d arcs, but have you tried changing your UCS to a side view of the 2 parts you are connecting and creating an arc from there?

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: 3d arc, how to do it?
« Reply #2 on: April 24, 2006, 05:28:18 PM »
i tried a side view, and iso. I even tried a new ucs on the plane b/t the 2 parts.  No go
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Lin-Z

  • Guest
Re: 3d arc, how to do it?
« Reply #3 on: April 24, 2006, 05:43:43 PM »
OK i got it to work by setting up the side view UCS, drawing a full circle, trimming and then usign the grips to make it less of a half-circle.  there has got to be an easer way tho  :-o

Bryco

  • Water Moccasin
  • Posts: 1883
Re: 3d arc, how to do it?
« Reply #4 on: April 24, 2006, 06:03:57 PM »
I'll see if I can do a little vba tonight. I think if you pick 2 points it shouldn't be too hard to make an polyline w/ a thickness so it will hide nicely

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: 3d arc, how to do it?
« Reply #5 on: April 24, 2006, 06:10:04 PM »
also, there is the height difference b/t the parts.  Good idea witht he circle though.  I will try that
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

RbtDanforth

  • Guest
Re: 3d arc, how to do it?
« Reply #6 on: April 24, 2006, 06:18:36 PM »
I'll see if I can do a little vba tonight. I think if you pick 2 points it shouldn't be too hard to make an polyline w/ a thickness so it will hide nicely

Unless you use a 3d polyline you will still have to have the new UCS or create it in the regular ucs and rotate it 3d.

A nice effect, if it fits the design need, is to create the polyline and extrude a circle along a path (the polyline) then it will have 3d weight and hide nicely.

A wide or wide and thick polyline can have weirdness if you have to work with it (only the center can be picked etc). A 3d polyline also has limitations. Or did last I looked.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: 3d arc, how to do it?
« Reply #7 on: April 24, 2006, 08:04:58 PM »
Dragon you dont need a ucs, just the math to tell it what plane to be on .

Cmdrduh I would be tempted to make the height a percentage of the distance betwwen the picked points.
Getpointex is in downloads.
Code: [Select]
Sub PolyArc3d()

Dim P1, P2, P3
Dim MidP(2) As Double
Dim dHt As Double, dBulge As Double '
Dim dist As Double
Dim oPline As AcadLWPolyline
Dim N As Variant
Dim dElev As Double
Dim Pts(3) As Double
Dim util As AcadUtility

Set util = ThisDrawing.Utility
P1 = GetPointEX
P2 = GetPointEX(P1)
dHt = ThisDrawing.Utility.GetDistance(, vbCrLf + "Type the height:")

MidP(0) = P1(0) + 0.5 * (P2(0) - P1(0))
MidP(1) = P1(1) + 0.5 * (P2(1) - P1(1))
MidP(2) = P1(2) + 0.5 * (P2(2) - P1(2))
dist = Length(P1, MidP)
MidP(2) = MidP(2) + dHt
P3 = MidP

N = NormalFromPoints(P1, P2, P3)
P1 = util.TranslateCoordinates(P1, acWorld, acOCS, False, N)
P2 = util.TranslateCoordinates(P2, acWorld, acOCS, False, N)
P3 = util.TranslateCoordinates(P3, acWorld, acOCS, False, N)
dElev = P1(2)
dBulge = Tan(dHt / dist)
Pts(0) = P1(0): Pts(1) = P1(1)
Pts(2) = P2(0): Pts(3) = P2(1)
Set oPline = ThisDrawing.ModelSpace.AddLightWeightPolyline(Pts)
oPline.SetBulge 0, -dBulge
oPline.Elevation = dElev
oPline.Normal = N
oPline.ConstantWidth = 0.1

End Sub




Public Function Length(Startpoint As Variant, Endpoint As Variant) As Double

Dim Stx As Double, Sty As Double, Stz As Double
Dim Enx As Double, Eny As Double, Enz As Double
Dim dX As Double, dY As Double, dZ As Double
Dim i As Integer
If IsEmpty(Startpoint) Then Err.Raise 13
i = UBound(Startpoint)
If UBound(Endpoint) = i Then
If i > 0 Then
Stx = Startpoint(0): Sty = Startpoint(1)
Enx = Endpoint(0): Eny = Endpoint(1)
dX = Stx - Enx
dY = Sty - Eny
If i = 1 Then
Length = Sqr(dX * dX + dY * dY)
Else
Stz = Startpoint(2): Enz = Endpoint(2)
dZ = Stz - Enz
Length = Sqr((dX * dX) + (dY * dY) + (dZ * dZ))
End If
Else
Exit Function
End If
Else
Exit Function
End If

End Function






Function NormalFromPoints(P0, P1, P2) As Variant
'n = uv = (V1-V0)(V2-V0)
Dim X1 As Double, X2 As Double
Dim Y1 As Double, Y2 As Double
Dim Z1 As Double, Z2 As Double
Dim Unit As Double
Dim x(2) As Double
Dim y(2) As Double
Dim N(2) As Double
'Get distance from zero
x(0) = P1(0) - P0(0): y(0) = P2(0) - P0(0)
x(1) = P1(1) - P0(1): y(1) = P2(1) - P0(1)
x(2) = P1(2) - P0(2): y(2) = P2(2) - P0(2)
'get CrossProduct
N(0) = x(1) * y(2) - x(2) * y(1)
N(1) = x(2) * y(0) - x(0) * y(2)
N(2) = x(0) * y(1) - x(1) * y(0)
'Convert to unit normal
Unit = Sqr(N(0) * N(0) + N(1) * N(1) + N(2) * N(2))
N(0) = N(0) / Unit: N(1) = N(1) / Unit: N(2) = N(2) / Unit
NormalFromPoints = N

End Function


RbtDanforth

  • Guest
Re: 3d arc, how to do it?
« Reply #8 on: April 24, 2006, 10:11:45 PM »
Cmdr
 Are you making one of these and blocking it, or are you making many different ones to be automatically produced?

If it is not to be automatically generated umpteen times then a lisp routine (much less C variants ) might be a bit of overkill? Even then I find the direct method (you would use to actually draw a thing) better than some fancy derivation no matter how cute.

To do all that to produce a wide polyline at a perpendicular instead of a real 3d object :ugly:

Bryco

  • Water Moccasin
  • Posts: 1883
Re: 3d arc, how to do it?
« Reply #9 on: April 24, 2006, 10:59:40 PM »
Dragon, making a solid is not difficult but it does significantly  increase the overhead.
CmdrDuh can do that easily if he wants to.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: 3d arc, how to do it?
« Reply #10 on: April 25, 2006, 09:54:54 AM »
I intend to extrude a circle along the arc once I figure out how to do it.  Im going to try the code above and see what happens.  Thanks everyone, I'll keep you posted.

BTW  all the bus you see is circles extruded along a path, which was defined by bus centerlines.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: 3d arc, how to do it?
« Reply #11 on: April 25, 2006, 10:39:36 AM »
Bryco, that is awsome!!!!!!!!  it draws the arcs perfectly.  What I find interesting, is you did it through code, yet I couldn't get it to draw manually.  My goal was to figure out how to do it manually, then write code.  Thnks
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: 3d arc, how to do it?
« Reply #12 on: April 25, 2006, 10:49:12 AM »
What is the function of the height?  My first test there was a 12 inch height difference, which looked awesome.  The second one had a 7 foot difference, which looked weird.  I redid it with 12 and 24 inch difference (experimentation at this point) and it looked great again.  Maybe chord height?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Bryco

  • Water Moccasin
  • Posts: 1883
Re: 3d arc, how to do it?
« Reply #13 on: April 25, 2006, 11:13:29 AM »
Thanks CmdrDuh.
The ht is used to set the bulge, that's why you may want to set the ht as a percentage of the distance between the 2 points.
After doing all your curves you will find it is easy to grip them to where you want.

BTW best manual way is to make 1 arc the way you like it. Array it a 100 to give you plenty to use. Use Align command to put it where you want it. (Enter at this prompt  "Specify third source point"
"Scale objects based on alignment points? [Yes/No] <N>:"   type y  )
Code wise I am not good at 3d translations to mimic align, but if you can do I'ld love to have that.

RbtDanforth

  • Guest
Re: 3d arc, how to do it?
« Reply #14 on: April 25, 2006, 04:06:10 PM »
I don't know how it would happen in VBA but the Lisp command Trans will translate the number between the wcs, the current ucs, an object's ucs, or the display. It doesn't do hypothetical ucs's, but you could make the hypothetical ucs the current ucs and measure that.

I find it easy enough to bounce the ucs all over as needed, as it is easy to bounce it back.
Quote
BTW best manual way is to make 1 arc the way you like it. Array it a 100 to give you plenty to use. Use Align command to put it where you want it.
I would make it and block it, that way it is always available. you can even set the ucs at the base of a regular arc and rotate the x 90 degrees, then the block will insert at 90 degrees z when inserted in the wcs.

I even wrote a little lisp routine for when I needed to insert a batch of the same block.
Code: [Select]
;insert many

(defun C:IM (/ a s r aq ax)
(setq aq  (getvar "attreq")
      A(ENTGET (CAR (ENTSEL "\tPICK BLOCK?..")))
      AX(CDR(ASSOC 2 A))
      S(CDR (ASSOC 41 A))
      R(CDR(ASSOC 50 A) )
      )(setvar "attreq" 0)
(while t (command ".insert" AX "s" S "r" PAUSE PAUSE PAUSE )(PRINC AX))
(setvar "attreq" aq)(TERPRI)
)

I wrote it when I had to place several hundred spotlights pointing at the various decorations in a bobslead ride.

If you make your insertion point the alignment point and match the rotation you can place hundreds in a few minutes.