How To Determine Object Reference Point Programmatically? S’abonner

0
Avatar
Legacy Poster

I use the X and Y properties of the designobject in an application which document the labels' contents. They are relative to the object reference point (and the template's reference point which is the same for all objects on that template). How can I programmatically get the individual object's object reference point so the actual X and Y can be calculated?

 

Thanks, Ira

8 commentaires

0
Avatar
Ian Cummings
Modérateur
Actions pour les commentaires Permalien

You can get/set the X/Y property of each design object.

 

Here is an example of setting the X/Y property.

// Declare a BarTender application variable 
BarTender.Application btApp; 

// Declare a BarTender document variable 
BarTender.Format btFormat; 

// Declare a BarTender design object variable 
BarTender.DesignObject btObject; 

// Create a new instance of BarTender 
btApp = New BarTender.Application();

// Set the BarTender application visible 
btApp.Visible = true;

// Open a BarTender document 
btFormat = btApp.Formats.Open("c:\\Format1.btw", false, "");

// Set the object variable 
btObject = btFormat.Objects.Find("Box 1");

// Set the location of the box object 
// 1.5 in from the left and 2.5 in from the top 
btFormat.MeasurementUnits = BarTender.BtUnits.btUnitsInches;
btObject.X = 1.5;
btObject.Y = 2.5;

// End the BarTender process 
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

I am already getting the X and Y, but they are being offset by the reference point of the object. The object reference point of some objects is bottom left and other objects are have different reference points set as you can see in the attached. If you change the object reference point to a different place on the object, the X and Y come back the same even though the effective position of the object is different. Again, how do you determine the object reference point setting? Bug?

0
Avatar
Ian Cummings
Modérateur
Actions pour les commentaires Permalien

Without trying this myself, are you saying that the X/Y positioning is based on the reference point of the object, and therefore the apparent positioning of objects can give unexpected results.  Any reason why you don't just select the reference point to be consistent for all objects?  For example, select all objects, open the properties, and set the reference point position.  I don't see a property to get/set the reference point of the object in VB script, so it looks like we lack what would be a useful feature for you.

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

Correct. Our application has to deal with our customers' labels as they have modified them. We give them "template" labels and they change elements in the labels, sometimes adding to the label. At application startup, the labels are processed to determine the design object names. An algorithm is applied to match the substring names to the design object names, and the substring names are used to fill some data objects. Think in terms of outputting a variable format bill of lading/shipping label that lists the contents onto preprinted forms.

 

We (at runtime) cannot set the labels object reference point nor do we have access to the clients' systems to apply consistent object reference points. Clients sometimes change the reference points to get more precise alignment of related objects (think top of text box immediately under or touching the text box above it).

 

It is a missing property of the design object. Similarly, the correspondence between design object and the substring to set it is missing.

 

Regards, Ira

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

I am having the exact same issue with text fields and boxes.  There should be a way to get the absolute X and Y values (as well as width and height for paragraphs).

 

I'm currently trying to get down through the Bartender.BtObjectType.btObjectText to see if there's anything more appropriate at a deeper level but so far have found nothing.

 

Any help on this would be greatly appreciated.

 

Thanks,

 

Daryl

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

So I've been looking at this on and off for a while and have come up with a workaround.  I open each label in BarTender then do Edit > Select All followed by Edit > Properties....  Then in the properties dialog box I go to Group Position and then on the right hand side go to the Object Reference Point drop down box and select Top Left and then Close. This aligns all objects to top left and allows me to make the necessary modifications without messing up the positions.

 

This takes around 10 seconds per label and is painfully boring but robust (i.e. you're not trying to select individual elements).

 

Now if only there were a way to automate this...   <_<

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

I appreciate the technique you are using, but that only works if you the developer have control over the labels. The customers have their own unique label designs and modify them for their needs.

 

Thanks, Ira

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

As far as I can tell changing the object reference point should not change the label design.  The X and Y coordinates should update when you modify the object reference point so that a new anchor point is used without altering the position of the object.

Vous devez vous connecter pour laisser un commentaire.