ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

wcstoucs? Where are my lines????

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
213 Views, 4 Replies

wcstoucs? Where are my lines????


 

i draw a line like it is show in the codesamples
from autodesk.

 

 

 ads_point pt1, pt2;

 

    if ((retval =
acedGetPoint(NULL, "select a point:", pt1)) != RTNORM)

    if ((retval =
acedGetPoint(pt1, LoadMyResourceString(IDS_STRING106), pt2)) ==
RTNORM)

 

  // create
the line 

  AcDbLine* pLine = new
AcDbLine(asPnt3d(pt1), asPnt3d(pt2));

 

 

this works fine with the wcs, but if the ucs is
moved or rotated

then the lines appear somewhere els.

 

do i have to translate all points? and how it is
done?

 

 

regards

chris


4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

chris,

 

acedGetPoint() allways return the point on
UCS.

In other hand, when you create a line its points
passed to the constructor are expected to be on WCS.

 

So, you must convert from UCS to WCS.

When your current UCS is the WCS everything works
fine because they are identical.

 

Use acedTrans() to do that. (Chapter 10 -
Coordinate System Transformations)

 

Regards,

Fernando.


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


 

i draw a line like it is show in the codesamples
from autodesk.

 

 

 ads_point pt1, pt2;

 

    if ((retval =
acedGetPoint(NULL, "select a point:", pt1)) != RTNORM)

    if ((retval =
acedGetPoint(pt1, LoadMyResourceString(IDS_STRING106), pt2)) ==
RTNORM)

 

  // create
the line 

  AcDbLine* pLine = new
AcDbLine(asPnt3d(pt1), asPnt3d(pt2));

 

 

this works fine with the wcs, but if the ucs is
moved or rotated

then the lines appear somewhere els.

 

do i have to translate all points? and how it is
done?

 

 

regards

chris


Message 3 of 5
Anonymous
in reply to: Anonymous

hi fernando,

 

thanks for answering me, but it seems to be
complicated to switch around between

the coordinatesystems. how is the best way to
handle this?

always to transform the points to the
wcs?

do i have to transform back from wcs to ucs in a
case?

which case could that be?

 

regards,

chris


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

chris,

 

acedGetPoint() allways return the point on
UCS.

In other hand, when you create a line its points
passed to the constructor are expected to be on WCS.

 

So, you must convert from UCS to
WCS.

When your current UCS is the WCS everything works
fine because they are identical.

 

Use acedTrans() to do that. (Chapter 10 -
Coordinate System Transformations)

 

Regards,

Fernando.


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


 

i draw a line like it is show in the
codesamples from autodesk.

 

 

 ads_point pt1, pt2;

 

    if ((retval =
acedGetPoint(NULL, "select a point:", pt1)) != RTNORM)

    if ((retval =
acedGetPoint(pt1, LoadMyResourceString(IDS_STRING106), pt2)) ==
RTNORM)

 

  // create
the line 

  AcDbLine* pLine = new
AcDbLine(asPnt3d(pt1), asPnt3d(pt2));

 

 

this works fine with the wcs, but if the ucs is
moved or rotated

then the lines appear somewhere
els.

 

do i have to translate all points? and how it
is done?

 

 

regards

chris


Message 4 of 5
Anonymous
in reply to: Anonymous

chris,

 

Generally ObjectARX trigonometric functions works
with points at WCS.

So you have to be aware when passing points to
prevent unexpected results.

 

Below are an explanation and a example extracted
from ObjectARX SDK Documentation:

 


size=2>---------------------------------------------------------

int
acedTrans(const ads_point pt, const struct
resbuf* from, const struct resbuf* to, int disp,

ads_point result);

 

Include File:
size=2>acedads.h

 

Translates a point or a displacement from one
coordinate system into another.
Interprets the pt argument as either a
three-dimensional point or a three-dimensional displacement vector. The
from
 argument specifies the coordinate system in which pt is expressed,
and the to argument specifies the coordinate system of this function's result.
If the disp argument is nonzero, pt is treated as a displacement vector;
otherwise, it is treated as a point.

 

The from and to arguments can specify a coordinate
system in any of the following ways:

An integer code (restype == RTSHORT) that specifies
the WCS, current User Coordinate System (UCS), or current Drawing Coordinate
System (DCS) (of either the current viewport or paper space), as described in
the following table.
 An entity name (restype == RTENAME), as returned
by one of the entity name or selection set functions. This specifies the ECS of
the named entity.

 

For planar entities, the ECS can differ from the
WCS. If the ECS does not differ, conversion between ECS and WCS is an identity
operation.

A 3D extrusion vector (restype == RT3DPOINT). This
is another method of specifying an entity's ECS.

Extrusion vectors are always represented in World
coordinates; an extrusion vector of (0,0,1) specifies the WCS.

 

Coordinate system codes:

 

Code Coordinate system
0 World
(WCS)
1 User (current UCS)
2 Display:DCS of current viewport
when used with code 0 or 1DCS of current model space viewport when used with
code 3
3 Paper space DCS (PSDCS; used only with code 2)

Warning The paper space DCS (PSDCS) can be
transformed only to or from the model space DCS. Therefore, if the from argument
equals 3, the to argument must equal 2, and conversely.

If acedTrans() succeeds, it returns RTNORM;
otherwise, it returns an error code. When acedTrans() fails, it sets the system
variable ERRNO to a value that indicates the reason for the
failure.

 


size=2>-------------------------------------------------

The following example translates a point from the
WCS into the current UCS.

 

ads_point pt, result;
struct resbuf fromrb,
torb;

 

pt = 1.0;
pt = 2.0;
pt = 3.0;

 

fromrb.restype = RTSHORT;
fromrb.resval.rint =
0; // WCS 

torb.restype = RTSHORT;
torb.resval.rint = 1;
// UCS 

 

// disp == 0 indicates that pt is a point: 

acedTrans(pt, &fromrb, &torb, FALSE,
result);

 

If the current UCS is rotated 90 degrees
counterclockwise around the world Z axis, the call to acedTrans() sets the
result to the point (2.0,-1.0,3.0). However, if acedTrans() is called as shown
in the following example, the result is (-2.0,1.0,3.0).

 

acedTrans(pt, &torb, &fromrb, FALSE,
result);


size=2>--------------------------------------------------------------------------

 

Regards,

Fernando.


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

hi fernando,

 

thanks for answering me, but it seems to be
complicated to switch around between

the coordinatesystems. how is the best way to
handle this?

always to transform the points to the
wcs?

do i have to transform back from wcs to ucs in a
case?

which case could that be?

 

regards,

chris


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

chris,

 

acedGetPoint() allways return the point on
UCS.

In other hand, when you create a line its
points passed to the constructor are expected to be on WCS.

 

So, you must convert from UCS to
WCS.

When your current UCS is the WCS everything
works fine because they are identical.

 

Use acedTrans() to do that. (Chapter 10 -
Coordinate System Transformations)

 

Regards,

Fernando.


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


 

i draw a line like it is show in the
codesamples from autodesk.

 

 

 ads_point pt1, pt2;

 

    if ((retval =
acedGetPoint(NULL, "select a point:", pt1)) != RTNORM)

    if ((retval =
acedGetPoint(pt1, LoadMyResourceString(IDS_STRING106), pt2)) ==
RTNORM)

 

  // create
the line 

  AcDbLine* pLine = new
AcDbLine(asPnt3d(pt1), asPnt3d(pt2));

 

 

this works fine with the wcs, but if the ucs
is moved or rotated

then the lines appear somewhere
els.

 

do i have to translate all points? and how it
is done?

 

 

regards

chris


Message 5 of 5
Anonymous
in reply to: Anonymous

hi,

 

i wrote 2 funktions to transform the
coordinates:

 

int UCStoWCS(ads_point pt1, ads_point
pt2)
 {
 TRACE0( " UCStoWCS() entered\n" );

 

 //Convert the UCS to WCS
 struct
resbuf fromrb, torb;

 

 fromrb.restype = RTSHORT;

 fromrb.resval.rint = 1; // UCS 

 

 torb.restype = RTSHORT;

 torb.resval.rint = 0; // WCS 

 

 // disp == 0 indicates that pt is a
point: 
 return acedTrans(pt1, &fromrb, &torb, FALSE,
pt2);
 }


size=2>/////////////////////////////////////////////////////////////////

int WCStoUCS(ads_point pt1, ads_point
pt2)
 {
 TRACE0( " WCStoUCS() entered\n" );

 

 //Convert the WCS to UCS
 struct
resbuf fromrb, torb;

 

 fromrb.restype = RTSHORT;

 fromrb.resval.rint = 0; // WCS 

 

 torb.restype = RTSHORT;

 torb.resval.rint = 1; // UCS 

 

 // disp == 0 indicates that pt is a
point: 
 return acedTrans(pt1, &fromrb, &torb, FALSE,
pt2);
 }

 

may they help you, define them as
globals,

then you have always access.

 

chris

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost