X8 - Polyline Labels Fails


JiAngelo
 Share

Recommended Posts

Love the idea....but what's the use of an "Object Specific Area (%area%) that doesn't round?

 

  • My old method, a text macro %ObjectArea% [=area.round] was context "Reference Object" and didn't work on labels.  Re-contexting it to "Owner Object" broke the macro on my other referenced objects, but it then started working for use in polyline labels.  In the short term I've created two duplicate macros labeled %ObjectArea-Owner% and %ObjectArea-Referenced% - cumbersome but it works.  I'd rather not have to duplicate all my macros - but I love not having to chase and ensure the arrows and referenced objects remain touching when I'm moving things around.

 

Next, unless I'm missing something, Labels are all the same size, they all map to the same layer "Polylines, Labels", so their text properties are identical and, thus far, I cannot find how to differentiate them - so again, I'm forced to find a work around, versus just plain working..

 

Last, when are you "chief" guys going to hire Joe Carrick? - He seems to be the only guy out there explaining what the manual you've refuse thus far to provide for Ruby and Macros....And I'm tired of piecing it together by scouring this forum.  (For instance, I just found Joe has posted a method which tests and thereby combines both my separate macro's above - I just don't have time to learn it just yet cause I have to get some actual work done tonight.) 

 

Very frustrating.  :wacko:  

Link to comment
Share on other sites

John,

 

Here's a trick that makes a "No Context" macro work for either "Owner" or "Reference" objects.

 

nplaces = 2

x = 0

begin

  x = owner.area

rescue

  begin

    x = referenced.area

  rescue

  end

end

x.round(nplaces)

 

The above will never produce an evaluation error.  The "begin/rescue/end" sequences trap the potential errors.

 

hth, Joe

Link to comment
Share on other sites

John,

 

Another trick for Leader Lines to help the connection is to use a Fill or PSolids.  This maintains the connection much better than the perimeter of a standard PLine.

 

At the UFP/UGM Dermot commented:  "I suppose now you'll want Rich Text Labels."  To which all of us on the UFP responded "YES!!!" :wub: 

 

I wouldn't hold my breath on getting that anytime soon. ;)

 

BTW, I use very few of the "Object Specific" macros that Chief provides because you can not format or calculate based on those results.

Link to comment
Share on other sites

Joe:

 

I discovered that one several years ago but haven't used it in some time now.

 

A more compact version is:

 

referenced ? obj = referenced : obj = owner

 

# Then add your code using obj or whatever

 

obj.area.round(2)

 

It has the advantage is not using the error catch in case you have to use it later giving cleaner code. Also only one line at the top of every macro.

 

enjoy.

Link to comment
Share on other sites

Nice Gerry.  I need to look at that syntax.  Is it documented someplace?  I can't seem to find it in my Ruby sources.

 

BTW, sometimes I use the error trapping to actually return a "descriptive error" such as:  "area doesn't exist as an attribute for this object".  I would have inserted that after the second "rescue" in the above example.

Link to comment
Share on other sites

You won't find any documentation in Chief --

Just a standard conditional statement in most languages. Take a look at the "little book of ruby"

 

And your right, only error trapping returns the error message but you can also use the "evaluation error" button in the MM DBX. I don't bother printing error messages as RUBY is considered the worst language in analyzing/issuing  descriptive error messages. Mostly wrong with complicated scripts.

Link to comment
Share on other sites

I find the "Little Book of Ruby" useful only to a certain point.  The official Ruby site has much better documentation but your

 

referenced ? obj = referenced : obj = owner

 

code isn't something I understand and I've not been able to find any explanation so far.  Can you explain how this is interpreted?

Link to comment
Share on other sites

I'm afraid i might only add to the confusion , but here goes.

 

referenced and owner in Chief and in ruby are not classes (objects). They are simply methods in the top main ruby work-space. They return a derived class from NVPublisher (empty class). They then add several instance_methods to that derived object corresponding to the attributes Chief wants to make available for the object selected.  Each added method, of course, as created by Chief, contains the address of the selected object on the "C" side that Ruby interfaces with.

 

So if nothing is selected, nothing can be referenced, so the method must return a nil. In the conditional above a nil is always false and anything else (including 0) is true. So if referenced returns a object it is evaluated as true and the first statement is executed, if a nil is returned, nothing is selected and a  false is returned meaning reference is not used so owner must be.  if nether is selected both will return a nil but it doesn't mater as a exception will be throw on a nil reference.You could use the same statement above  by testing for owner and just reverse the conditionals. Since the methods return a object, you simply set a variable  to that object, because in Ruby all values (most) are returned by reference not value. Using the equivalence is the same as using the original object. This is also the bases of my video which describes how to address any object even though it is not selected and outside of a label. Once you have the UUID, it does not change,so you can address the object outside of any label or reference. The problem is if you try to address a deleted object. you will address some deleted memory and Chief will throw a C exception. They have refused to fix this as I expect they simply don't want people using attributes outside of labels.

 

 

This is also why Doug said a while back that adding any attribute will only take one/two lines of code per attribute. The UUID of the object is always passed  back so the only thing needed is the name of the attribute which I suppose on Chief's end is just a lookup table or perhaps a hard coded pointer.

 

This is why I always said that all DBX data is already available to us. If Chief would simply pass back the entire object dataset as pointed to by its UUID instead of individual attributes, we would have all the info by just unpacking the data ourselves. Ruby is a ideal language to do this and very simple to do. Chief need only publish the format of their stored dataset for each object. Their aren't that many object types in Chief to be a burden, and no need to write code for every new attribute or revision.

 

BTW, I believe the original developers anticipated doing something like this in some future release but for reasons still unknown were pulled off the project.

 

Clear as MUD?

Link to comment
Share on other sites

Thanks Gerry,

 

So as I understand your code it's the same as:

 

if referenced ?

  obj = referenced

else

  obj = owner

end

 

but just in a single line of code. 

 

I also understand the UUID problem - and really don't understand why CA has been so reluctant to make the data available.  IMO, it has the potential to make Chief a super BIM Application.

Link to comment
Share on other sites

You guys with your Ruby and Macro's are something great and I am envy, all I know with Joe and his macros and the macro of the month has made things a lot better for me and I thank you for that, just wish chief would do more with a macro lib to be able to find things better and faster.

 

Thank you guys

  • Upvote 1
Link to comment
Share on other sites

So as I understand your code it's the same as:

 

if referenced ?

  obj = referenced

else

  obj = owner

end

 

but just in a single line of code. 

 

 

 

 

Yes - but without the question mark

Got it.

I think for most people the single line syntax is not as easy to understand.  It's just a little too cryptic.

 

OTOH, the concept of setting obj this way is very nice.  I can clean up a lot of spaghetti code and eliminate quite a lot of unnecessary conditional processing.

 

Thanks again.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share