Prof. Monster's LinkLib 1.13 for linked groups

Prof. Monster presents:

The LinkLib 1.13!
With simulated “Instance properties”.
Easier access to the Pivot and Base via Instance class.

(still full 2.49, 2.5+, 2.6+ compatible)

As an side effect of the MouseOrbiter the former Group Scripts were renamed to LinkLib and can now be used as Python modules.

[Edit] Added three VideoTutorials at the end of this post [/edit]

There are some Python-Module-Controller-ready functions in the module:

  • LinkLib.linkPivotAndBase: This module (applied to the base object of the group) will look for the pivot object that added the group. The pivot must have a property with the name that is defined in the base object’s property baseType. (See picture: Base object property baseType=“GroupID”, Pivot property GroupID exist. Recommended baseType is the name of the group).


  • LinkLib.linkSceneObjects: Links all objects in a scene
  • LinkLib.parent:This module parents the base object the pivot.
  • LinkLib.reparent:This module parents the base object to the parent of the pivot. This allows the pivot to perform other transformations (rotation, position etc.).


  • LinkLib.copyProps: This module copies the properties of the pivot object to the base object.

  • LinkLib.copyPropsToBase: Copies the existing properties from this pivot object to the base object.

  • LinkLib.copyPropsFromPivot: Copies the existing properties from the pivot object to the this base object.

  • LinkLib.copyPropsAnd: Copies the existing properties from the pivot object to
    the base object of the group instance if all sensors are positive

  • LinkLib.copyPropsOr: Copies the existing properties from the pivot object to
    the base object of the group instance if at least one sensor is positive

  • LinkLib.copyPropertyToPivot: copies properties from base to pivot (from base only)

  • LinkLib.parentPivotToOwner: Parent the pivot to the controller’s owner

  • LinkLib.parentPivotsChildrenToOwner: Parent the pivot’s children to the controller’s owner
    [LIST]

  • if the property mustHave with a list of property names exists only objects with at least one of the properties will be parented.

  • LinkLib.printLinks: prints pivot and base information

  • LibLink.printAll: prints all information
    [/LIST]
    History
    1.13

  • replaced cache wich instance. The instance can be applied to all instance objects with addObjTreeToInstance

  • addObjTreeToInstance() applies all parented objects to the instance of this object.

  • setInstanceProperty() distributes the properties of the connected PropertySensors to all instance objects of this instance. This simulates “instance properties”.

1.12 - parenting makes the child no ghost now

  • added copyPropertyToPivot
    1.11 - added cascading property assignment (properties from pivot’s pivot)
  • API change! only properties that are defined at the base are copied!
    1.10 - removed “baseName” property
  • introduced LinkLibCache
    1.8 - compatible with 2.5
    1.7 - bugfix: parented pivots might get different position when the parent is rotated
    1.6 - enhanced parentPivotsChildrenToOwner to look for children with specific properties listed in property “mustHave”.
    1.5 - added getPivotInTree, parentPivotsChildrenToOwner
  • renamed parentPivot to parentPivotToOwner
    1.4 - added parentPivot, printLinks, printPivotForObj, printBaseForObj, printAll, copyPropsToBase, copyPropsFromPivot
  • BugFix copyProps does not copy the property Pivot, or baseType anymore
    1.3 - added copyPropsAnd, copyPropsOr
    1.2 - refactored the variables for property names,
  • replaced ‘has_key’ with ‘in’

Tutorials are in the next post

Happy blending
Monster

LinkLib.blend (version 1.13)

Video Tutorials

Part I - Basics and parent to pivot
showing

  • How to link Pivot and Base
  • How to parent the base to the pivot

(no sounds but with English subtitles)

Part II - Parent objects to instance objects
showing:

  • How to parent an object to the base
  • How to parent a selection of objects to the base
  • How to parent multiple objects to multiple different objects of the instance

Part III - Link from and to .blendfiles
showing:

  • how to create your own library file
  • how to create a file that uses the linked group
  • how to setup your group to run in your file

Exercise 1 - parent to pivot
Let the boat of outdoorItems follow it’s pivot object.

Happy blending
Monster

Monster,
Could you make a tarball or a zip of the scripts as pure .py files with some indication as to how to layout a directory structure such that they can be used as independent modules? (IOW, without having to Add them into a blend file.)

Thanks for this very cool script. IMHO the Game Engine is suffering a disconnect with the way ‘normal’ Blender handles dupligroups and your script is the only way around it as of 2.49b.

\d

Damn, I just saw that my .blend files are not attached. I will upload the this evening when I’m at home.

Ok, the demo files are attached.

I have my own version of a solution to the problem. I started a new thread here:
http://blenderartists.org/forum/showthread.php?p=1505248#post1505248

Thanks for the help and ideas, Monster.

\d

Thanks, Monster. Your stuff is pretty advanced. Maybe I’ll learn something.

Monster , where attached. files ?

The files are attached to the first post. The scripts are inside the .blend files

Updated the top post with some images

Updated LinkLib with version 1.5

How about a simple all-covering explanation on What this is and What it does?
Does this allow me to copy objects from one scene to another in real time, or does this allow me to refer to them…
I read but somhow i cant get it >.<

(also the relationship with the MouseOrbiter isnt clear to me, btw, why its called MOUSEorbiter, when objects should orbit… me confuse a bit)

Greets Equal

The mouseOrbiter is just an example and demonstrate the usage of LinkLib. It is called MouseOrbiter because if you move the MOUSE - the ORBITER and all its children circles around a center. E.g. you move the mouse left, the orbiter moves left on the orbit.

If you use addObject or Groups you might have discovered that the object (pivot) that adds the object (instance) has no further relationship to the added object.
Especially the objects of a group are not accessable in the Editor anymore. So you can’t parent anything to them or parent them to some other object.

That means if you move the pivot the objects of the instance do not move. (Keep in mind that instances can consists og more than one object.)

To solve this problem the LinkLib provides function for it (see the first post). So you can

  • parent instance objects to the pivot
  • copy properties from pivot to a instance object
  • parent the pivot to any object of the instance
  • parent the children of the pivot to any object of the instance

but cant you just use the Parent function?
like said object A.setParent(B)?
And for Groups just “for” loop them with setParent()?

Greets Equal, thanks for explanation.

The problem with group instances is: there can be more than one.
The questions are:

  • what objects belongs to what instance?
  • what pivot created the instance objects? (so you can copy any configuration from it)
    Keep in mind, only the pivot is accessable in Blender.

For a little help I added a video tutorial to the first post.

Monster

Two new videos were added to the top post.

I hope you enjoy
Monster

Updated version of linklib

Attachments

LinkLib.blend (55.5 KB)

Thanks Monster!

Carsten

Version 1.13 file:

Attachments

LinkLib.blend (56.9 KB)