Loading ...
Sorry, an error occurred while loading the content.

Re: [cc2-dev-l] Position of Symbols

Expand Messages
  • Christopher Golden
    ... Hmm, I m surprised that it is returning a zero length string, but even if it weren t, I don t think that it would return the string you want. EInfoName()
    Message 1 of 4 , Sep 3, 2000
    • 0 Attachment
      Bruce A. Carson wrote:

      > Also I expected the Symbol name (EInfoName(pEntRec)) to return the
      > name of the symbol used. It is always returning a zero length string.

      Hmm, I'm surprised that it is returning a zero length string, but
      even if it weren't, I don't think that it would return the string
      you want.

      EInfoName() should return a name denoting the type of the entity
      (e.g. "2D Smooth Polygon"), not the symbol name. I think that to
      get the name of the symbol in a symbol reference, you must look
      at the string held by pEntRec->SymRef.SName. This 32 character
      array should hold the name of the symbol that is being referenced.

      Hope this helps somewhat! I don't know about your other question,
      though...

      Take care,
      Christopher Golden
      golden@...
    • Peter Olsson
      ... The position of the symbol reference is determined by the TMat variable which holds the (symbol) transformation matrix to move the symbol to the correct
      Message 2 of 4 , Sep 3, 2000
      • 0 Attachment
        >I have been working on a simple xp program to return the location of
        >items in a drawing (x,y). The x,y of a Symbol reference does not
        >seem to be correct.

        The position of the symbol reference is determined by the TMat variable which holds the (symbol) transformation matrix to move the symbol to the correct place. You will need to extract the information from the transformation matrix.

        1. Just read the X,Y value (I hope I got the indexes right :) ):

        X=pEntRec->Symref.TMat.m41;
        Y=pEntRec->Symref.TMat.m42;

        Note: If you look at the table in the header file the transformation matrix is transposed compared to what my math books teach.


        2. Ask for specifications for the CTM (current transformation matrix)

        TSPEC2 *TSpec;
        LDSymTM(&pEntRec->SymRef.TMat);
        TSpec=CTMSPC2();

        TSpec->DeltaX and TSpec->DeltaY will hold your X and Y.


        3. Create a point and apply the CTM to it.

        GPOINT2 Pt={0,0};

        LDSymTM(&pEntRec->SymRef.TMat);
        TranP2(&Pt);

        Pt now points to your X,Y

        Good luck!

        Peter
      • Bruce A. Carson
        Peter, Christopher : Both your suggestions work wonderfully - except for Peter s #3 . That function is not defined for C , it is for Assembler (in
        Message 3 of 4 , Sep 3, 2000
        • 0 Attachment
          Peter, Christopher :

          Both your suggestions work wonderfully -
          except for Peter's #3 . That function is not defined for 'C', it is
          for Assembler (in XPSVC.CPY).

          I also found a fourth way to get the location- the Extents are stored
          as part of the symbol reference so the center of the symbol is the
          average X and average Y:

          (pRef->Low.x+ pRef->Hi.x)/2
          (pRef->Low.y+ pRef->Hi.y)/2

          Thanks,
          Bruce

          > -----Original Message-----
          > From: Peter Olsson [mailto:peter@...]
          > Sent: Sunday, September 03, 2000 3:21 PM
          > To: cc2-dev-l@egroups.com
          > Subject: Re: [cc2-dev-l] Position of Symbols
          >
          >
          >
          > >I have been working on a simple xp program to return the location of
          > >items in a drawing (x,y). The x,y of a Symbol reference does not
          > >seem to be correct.
          >
          > The position of the symbol reference is determined by the TMat
          > variable which holds the (symbol) transformation matrix to move
          > the symbol to the correct place. You will need to extract the
          > information from the transformation matrix.
          >
          > 1. Just read the X,Y value (I hope I got the indexes right :) ):
          >
          > X=pEntRec->Symref.TMat.m41;
          > Y=pEntRec->Symref.TMat.m42;
          >
          > Note: If you look at the table in the header file the
          > transformation matrix is transposed compared to what my math books teach.
          >
          >
          > 2. Ask for specifications for the CTM (current transformation matrix)
          >
          > TSPEC2 *TSpec;
          > LDSymTM(&pEntRec->SymRef.TMat);
          > TSpec=CTMSPC2();
          >
          > TSpec->DeltaX and TSpec->DeltaY will hold your X and Y.
          >
          >
          > 3. Create a point and apply the CTM to it.
          >
          > GPOINT2 Pt={0,0};
          >
          > LDSymTM(&pEntRec->SymRef.TMat);
          > TranP2(&Pt);
          >
          > Pt now points to your X,Y
          >
          > Good luck!
          >
          > Peter
          >
          >
          > To Post a message, send it to: cc2-dev-l@...
          > To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...
          >
        • Peter Olsson
          ... Sorry, I have written that glue routine myself. Include this ito your code: void _stdcall TranP2(void); void XPCALL _TranP2(GPOINT2 *Pt) { __asm mov esi,
          Message 4 of 4 , Sep 4, 2000
          • 0 Attachment
            >Both your suggestions work wonderfully -
            >except for Peter's #3 . That function is not defined for 'C', it is
            >for Assembler (in XPSVC.CPY).

            Sorry, I have written that glue routine myself. Include this ito your code:

            void _stdcall TranP2(void);

            void XPCALL _TranP2(GPOINT2 *Pt)
            {
            __asm mov esi, Pt;
            TranP2();
            }

            #define TranP2 _TranP2

            >I also found a fourth way to get the location- the Extents are stored
            >as part of the symbol reference so the center of the symbol is the
            >average X and average Y:
            >
            >(pRef->Low.x+ pRef->Hi.x)/2
            >(pRef->Low.y+ pRef->Hi.y)/2


            This will return the center of the symbol reference not the origin.

            Peter
          Your message has been successfully submitted and would be delivered to recipients shortly.