WCS movement?

WCS movement?

Anonymous
Not applicable
322 Views
3 Replies
Message 1 of 4

WCS movement?

Anonymous
Not applicable
I'm new to VBA, but have spent about one year creating solids in AutoCAD
using AutoLISP. I've only got that much AutoCAD experience also, so I'm a
relative newbie here. I'm rewriting an application in VBA (from AutoLISP)
and I have a question.

It seems to me that the VBA routines that create solids only create them in
relation to the WCS, not to the UCS. In AutoLISP, I used to create, move and
rotate the UCS all over the place when I created all the parts I did. I
can't do that now, because no matter where I move the UCS to, the part is
created in relation to the WCS, and in the same orientation. I belive that I
can rotate the object, but I'd like to keep things as close to the old
AutoLISP code as possible.

Am I beating my head against a wall trying to find a way to create the
solids in relation to the UCS?

Is there anyway to rotate or move the WCS?

Should I just put away my "we've always done it this way" glasses and pick
up a new set of "I've got to look at this a new way" specs?

Any help is greatly appreciated.

Eric Schultz
0 Likes
323 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Eric,



Our circumstances are similar (but different). I've been using AutoCAD for about a year and creating solids in VBA. I found precious little documentation that was easy to understand and have had to struggle my way through.



You are correct that VBA can only create solids relative to the WCS. There are two methods that assist with the necessary conversions though. TranslateCoordinates translates a point from one coordinate system to another coordinate system. Its a bit long and unwieldy so I wrote the following couple of functions to simplify my code.


Private Function WCStoUCS(ByVal ptv As Variant) As Variant
   WCStoUCS = ThisDrawing.Utility.TranslateCoordinates(ptv, acWorld, acUCS, False)
End Function

Private Function UCStoWCS(ByVal ptv As Variant) As Variant
   UCStoWCS = ThisDrawing.Utility.TranslateCoordinates(ptv, acUCS, acWorld, False)
End Function

The other method is the TransformBy method (and it's companion method GetUCSMatrix). These methods use Transformation Matrices to manage the manipulation. I suggest you don't even *try* to understand Transformation Matrics (unless you're an engineer or something) - just be assured in the knowledge that they are a mathematical model for mapping the coordinates from one Coordinate System to the other. To use this approach you create the solid in the WCS as you would want to in the UCS, then Transform it once you're finished. For Example:


PlaneMatrix = PlaneUCS.GetUCSMatrix()
Set GeneralSolid = ThisDrawing.ModelSpace.AddBox(ptv, GeneralLine.Length, SolidBreadth, SolidDepth)
GeneralSolid.Rotate3D pt1, pt2, RightAngle
GeneralSolid.TransformBy (PlaneMatrix)

Regards



Wayne Ivory
0 Likes
Message 3 of 4

Anonymous
Not applicable
Nice - I like the way you simplified these
Wayne.

 

Thanks,
--
Kevin

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Eric,

  
Our circumstances are similar (but different). I've been
using AutoCAD for about a year and creating solids in VBA. I found precious
little documentation that was easy to understand and have had to struggle my
way through.
  
You are correct that VBA can only create
solids relative to the WCS. There are two methods that assist with the
necessary conversions though. TranslateCoordinates translates a point from one
coordinate system to another coordinate system. Its a bit long and unwieldy so
I wrote the following couple of functions to simplify my code.
 
Private Function WCStoUCS(ByVal ptv As Variant) As Variant
   WCStoUCS = ThisDrawing.Utility.TranslateCoordinates(ptv, acWorld, acUCS, False)
End Function

Private Function UCStoWCS(ByVal ptv As Variant) As Variant
   UCStoWCS = ThisDrawing.Utility.TranslateCoordinates(ptv, acUCS, acWorld, False)
End Function

The other method is the TransformBy method (and it's companion
method GetUCSMatrix). These methods use Transformation Matrices to manage the
manipulation. I suggest you don't even *try* to understand Transformation
Matrics (unless you're an engineer or something) - just be assured in the
knowledge that they are a mathematical model for mapping the coordinates from
one Coordinate System to the other. To use this approach you create the solid
in the WCS as you would want to in the UCS, then Transform it once you're
finished. For Example:
 
PlaneMatrix = PlaneUCS.GetUCSMatrix()
Set GeneralSolid = ThisDrawing.ModelSpace.AddBox(ptv, GeneralLine.Length, SolidBreadth, SolidDepth)
GeneralSolid.Rotate3D pt1, pt2, RightAngle
GeneralSolid.TransformBy (PlaneMatrix)
Regards
  
Wayne Ivory
0 Likes
Message 4 of 4

Anonymous
Not applicable
Wayne,

 

Thanks so much for your response. It is very
helpful.

 

You're correct about the transformation matrix
being beyond most of us "common" folk. With these examples, I should be able to
do what I need to.

 

Eric

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Eric,

  
Our circumstances are similar (but different). I've been
using AutoCAD for about a year and creating solids in VBA. I found precious
little documentation that was easy to understand and have had to struggle my
way through.
  
You are correct that VBA can only create
solids relative to the WCS. There are two methods that assist with the
necessary conversions though. TranslateCoordinates translates a point from one
coordinate system to another coordinate system. Its a bit long and unwieldy so
I wrote the following couple of functions to simplify my code.
 
Private Function WCStoUCS(ByVal ptv As Variant) As Variant
   WCStoUCS = ThisDrawing.Utility.TranslateCoordinates(ptv, acWorld, acUCS, False)
End Function

Private Function UCStoWCS(ByVal ptv As Variant) As Variant
   UCStoWCS = ThisDrawing.Utility.TranslateCoordinates(ptv, acUCS, acWorld, False)
End Function

The other method is the TransformBy method (and it's companion
method GetUCSMatrix). These methods use Transformation Matrices to manage the
manipulation. I suggest you don't even *try* to understand Transformation
Matrics (unless you're an engineer or something) - just be assured in the
knowledge that they are a mathematical model for mapping the coordinates from
one Coordinate System to the other. To use this approach you create the solid
in the WCS as you would want to in the UCS, then Transform it once you're
finished. For Example:
 
PlaneMatrix = PlaneUCS.GetUCSMatrix()
Set GeneralSolid = ThisDrawing.ModelSpace.AddBox(ptv, GeneralLine.Length, SolidBreadth, SolidDepth)
GeneralSolid.Rotate3D pt1, pt2, RightAngle
GeneralSolid.TransformBy (PlaneMatrix)
Regards
  
Wayne Ivory
0 Likes