Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    How to follow a Ttargetexpression

    Scheduled Pinned Locked Moved SDK Help
    6 Posts 0 Posters 483 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 22/03/2011 at 17:19, xxxxxxxx wrote:

      [USERFORM][p]User Information:[/p]Cinema 4D Version:   R12 
      Platform:   Windows  ;   
      Language(s) :     C++  ;   
      [p]---------[/p][/USERFORM] Hi!
       
      I try to follow a link from a TargetExpression, but can't figure out how to do that ...
      I need to know on which linked object the target-camera looks
       
      op is the camera-object of type Ocamera
       
      BaseTag* tag = op- >GetTag(Ttargetexpression);
      **GeData p;
      bool ok = tag->GetParameter(1001, p, DESCFLAGS_GET_0);  // ok == true
      LONG type = p.GetType();                                // type == 133 ALIASLINK
      BaseLink* bl = p.GetBaseLink();                         // bl != null    
      **
      BaseObject* target = (BaseObject * )bl;
      but this cast fails, you can't call target->GetName() : you get an ESP error
      and get wrong result for:
      Vector position = target- >GetAbsPos();
      position is it I'm intrested in.
       
      I also tested: bl->GetLink, bl->ForceGetLink, but no luck as well
       
      Could you post a working code snippet please?
       
      Thanks a lot for assistance.

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 22/03/2011 at 21:19, xxxxxxxx wrote:

        Well, a BaseLink is not a BaseObject derivative.  It is a class which stores a link to a BaseObject or other type derived from BaseList2D.  You need to call target = static_cast<BaseObject*>(bl->GetLink(doc));.  Then it will work if the link is set.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 23/03/2011 at 06:24, xxxxxxxx wrote:

          Howdy,

          I'd do it something like this:

          BaseDocument *doc = GetActiveDocument(); // needed if doc isn't passed to function
            
          BaseTag *tag = op->GetTag(Ttargetexpression);
          if(tag)
          {
          	BaseContainer *tData = tag->GetDataInstance();
          	if(tData)
          	{
          		BaseObject *target = tData->GetObjectLink(1001,doc);
          		if(target)
          		{
          			String tName = target->GetName();
          			Vector position = target->GetAbsPos();
          			
          			// ...the rest of your code for the target object
          		}
          	}
          }
          

          Adios,
          Cactus Dan

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 23/03/2011 at 14:44, xxxxxxxx wrote:

            Hi all!
             
            Thanks a lot for your suggestions!
             
            I tried your both methods and they won't work for me.
             
            Is there a difference if I execute this from an export-filter plugin.
            My intetion is to develop an special export-filter.
            Compilation is done with C++ and VisulaStudio 2010.
            Traversion of the object tree and write transformed data to output-file is no problem.
            Only getting the information for the linked object is the problem.
             
            I have written some lines of COFFEE to achieve this and it is no problem to get the desired data.
             
            Have I missed some preconditions?
             
            Many thanks in advance.

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 24/03/2011 at 07:48, xxxxxxxx wrote:

              Howdy,

              You'll probably need to post some example code of what you're trying to do, to get better suggestions.

              If you add print statements to the code I posted in "else" statements like this:

              BaseTag *tag = op->GetTag(Ttargetexpression);
              if(tag)
              {
                  // ..... rest of code
              }
              else GePrint("tag pointer is NULL");
              

              ... then you can see if the pointers are NULL, which could be one reason the code isn't working for you.

              Adios,
              Cactus Dan

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 24/03/2011 at 15:01, xxxxxxxx wrote:

                Howdy,
                 
                ok, I have tracked the problem down to:
                doc- >Polygonize();
                If I omit **doc- >Polygonize(); **than it works like expected! Thanks for your example!
                A search in the forum resulted in:
                **Topic: Instances dropped on Document::Polygonize
                **https://developers.maxon.net/forum/topic/3495/2913_instances-dropped-on-documentpolygonize
                 
                So I think it is the same cause of my problems.
                I will try the suggested solution and polygonize on an individual basis.
                 
                Thanks a lot for your assistance!
                 
                Bye!
                framer

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post