Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creating POINT in different UCS

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
vehlow
551 Views, 5 Replies

Creating POINT in different UCS

Hello everybody!

I would like create POINTS in different UCS with the function acdbEntMake ().

But I have serious troubles in calculation the correct angle for the GC 50. POINTS do not have an own OCS/ECS. I have the correct values of UCSXDIR, UCSYDIR and the vector for the GC 210. But what is the correct algorithm for calculating the angle in GC 50.

Thank you very much and many greetings.

LV

5 REPLIES 5
Message 2 of 6
daniel_cadext
in reply to: vehlow

Use AcGePoint3d::transformBy.

you can convert RT3DPOINT to/from AcGePoint3d using asDblArray() and asPnt3d() functions

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
Message 3 of 6
tbrammer
in reply to: vehlow

This should work:

 

double EcsRotation(const AcGeVector3d &ucsXdir, const AcGeVector3d &ucsYdir)	{
	AcGeVector3d ucsZdir = ucsXdir.crossProduct(ucsYdir);
	AcGeVector3d zPerp(ucsZdir.perpVector());
	return ucsXdir.angleTo(zPerp, ucsZdir);
}

double EcsRotation(AcDbDatabase* pDB)	{
	return EcsRotation(pDB->ucsxdir(), pDB->ucsydir());
}

 

 
 

 

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 4 of 6
vehlow
in reply to: tbrammer

Dear 'tbrammer': Thank you very much! It works great! One last question: if I wand to insert a simple text-entity in a ucs (using ocs/ecs) it needs a different angle as gc 50. Have you any idea? Looking forward. Many greetings!

Message 5 of 6
tbrammer
in reply to: vehlow

Why do you think text and point entities use different angles? I tried to create texts and points in different UCSs and found the GC 50 values to be just the same for both.

But in fact point entities behave different than other entities when they are rotated around arbitrary axes. Their GC 50 / Z-rotation value is not calculated correctly. See this screencast.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 6 of 6
vehlow
in reply to: tbrammer

Hello,

indeed, a point and a text have in the same UCS with 0 inserting rotation-angle different GC50. See the following pictures.  Test1.pngTest2.png

 

Nevertheless the angle in GC50 for Text-Entities I use the following code:

    // Einheitsvektor X-Achse WCS
    x_wcs[X]=1.0; x_wcs[Y]=0.0; x_wcs[Z]=0.0;
    // Einheitsvektor Y-Achse WCS
    z_wcs[X]=0.0; z_wcs[Y]=0.0; z_wcs[Z]=1.0;
    
    // UCS-Mode
    if (dgm->ucs_mode==true) {
        
        // Z-Achse UCS
        acdbUcs2Wcs (z_wcs, dgm->ucs_zdir,true);
        
        // Setzen des GC für TEXT
        acdbWcs2Ucs (z_wcs, z_ucs, true);
        acdbWcs2Ucs (x_wcs, x_ucs, true);
        p1[X]=0.0; p1[Y]=0.0;
        
        if ((fabsl(z_ucs[X])+fabsl(z_ucs[Y]))<DBL_EPSILON) {  // Z-Achse-UCS zu Z-Achse WCS parallel
            p2[X]=x_ucs[X]; p2[Y]=x_ucs[Y];
            dgm->ucs_tang = -acutAngle (p1, p2);
        }
        else {
            p2[X]=z_ucs[X]; p2[Y]=z_ucs[Y];
            dgm->ucs_tang = 2*M_PI-acutAngle (p1, p2)+M_PI_2;
        }
    }

So, everything is fine! Thank you to all of you and many greetings!

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report