Cleaning up Script

@john_pierson

I was wondering if you could look at a script I put together. It works, but it is a bit chunky and it feels like it could be slimmed down.

This script will place a window tag on the window and nudge it out a bit. It isolates the windows by parameter. The OOTB window tagging works well, but there is no way to offset the tag without first inserting it with a leader and I don’t want that.

What I have setup now requires the user to go into dynamo before each project and make sure the correct parameter is typed in for each window. In it’s simplest form you would have North, South, East, West so that it pushes the tag in the correct direction. Other than a few unique intputs, I’m running the same script multiple times.

The more I learn and read about Python, this almost seems like it could be an easy if/elif/else script. You would just need to define each of the differences and then note them later?

The difficult part seems that you would think it could be as easy as N/S/E/W but buildings have courtyards( like the one I’m in right now) or angles.

Any thoughts?

Thanks

Tag Windows_Offset_script.dyn (700.6 KB)

For literal window components, you should be able to use this node to just pull a vector from the window facing.

2 Likes

Could I get another nudge on this? I was thinking I could use those locations and just increase the vector to push the location out but it seems to tag them sporadically. By that I mean, there are windows that are next to each other that aren’t tagged with a similar offset.

@jacob.small

I found the thread below today and was wondering if the clockwork node you mentioned in that thread might be a better solution to placing a shifted tag.

Best to use the facing orientation method which John mentioned before.

The issue with your graph appears to be that for the elements being tagged you are using ALL the window elements in the project, while for the elements getting the facing orientation you are using only the windows in the view. Try removing the All Elements of Category node and only utilize the All Elements of Category In View node instead. This will also help to ensure you only place tags for windows you can see, as the “view” you tag will be the active view as well.

1 Like

I have actually already done that because that dawned on me as well. The script works like it should, as in it places a tag, but I don’t know how to tell it to offset the facing orientation so that tag isn’t’ placed on the center of the window.

Hi,

It’s probably less efficient, but you could also get the tags location after their creation and use a Geometry.Translate node to move the tags by an offset.
(Not sure if the OOTB Element.GetLocation and Element.SetLocation nodes work with tags but there are Tag GetLocation and a Tag SetLocation custom nodes in the Genius Loci package.)

Try putting the facing orientation into the “offset” variable. If you’re in mm you’ll likely want to scale this up by 1/2 of the thickness of your typical wall.

1 Like

So, this is the second time today where I have had an issue with a script or line of code that I am pretty sure should work but isn’t.

When I reach out and ask they suggest I put it back the way I had it. I do that and it worked that time. I used the facing orientation and then used vector.scale with a scale of 2 and it works perfectly.

Thanks for the help!

1 Like

Thanks for the suggestion of this node, I was able to get it to work!

1 Like