JiAngelo

X8 - Polyline Labels Fails

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:  

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Member Statistics

    27612
    Total Members
    6254
    Most Online
    kBdesignND
    Newest Member
    kBdesignND
    Joined
  • Similar Content

    • By ccarpenter18
      In X12 I've noticed that when using Structural Member Reporting in a material list, the price column in the list does not appear to be sensitive to whether a "per unit" or "per length" calculation is being performed by the material list.  In both cases, the material list appears to use the same Price variable in the Component Panel of each object.  Does anyone know of some Ruby scripting that could be used to correct this?  Off hand, I'm thinking of a macro inserted into the Price variable on the Component Panel of each structural member that would use the Material List row context to report a price that depends on how the row wants to use the Price.
    • By community
      Hello,
      Just throwing the question out here: Is it possible to write a custom script for X10 to make the program export a custom materials list with some calculated fields and some custom formatting, like a header with our logo?
      If so, would anyone have an idea where I could turn to have this done for me?
       
      Kind regards
    • By kylejmarsh
      Wondering if there's a way to drop the '0' which is generated in front of the schedule numbers. It adds size to my labels and most of the time there are less than 10 items so it wouldn't be confusing - but I haven't been able to find any options where we can omit this automatically generated zero.
       
      Anybody have any tips or insight?
       

    • By raltd9245
      Another Senior moment to start the Year. I wand to change the size and shape of door labels. HELP.
    • By BrownTiger
      The Andersen 100 Series windows [Fiberex] are always popular with a builders. Primarily, they offer different interior and exterior colors, not as ugly as some other Vinyl... Sometimes designer want to know if he is using standard vs custom sizes [adds +$$].
       
      So here is a validator macro, that can be assigned as a label or just executed in the tmm
       

       
      Free Macro, enjoy
      Code demonstrate use of Ruby arrays, and "any?" method.
       
      BT
      I also have A200,400, and pella.. But this will get you started if you are not 100% familiar with Ruby.
      Andersen100Units.json