Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring/hinge visual in plots #339

Open
AsgerKrllAnd opened this issue Oct 21, 2024 · 0 comments
Open

Spring/hinge visual in plots #339

AsgerKrllAnd opened this issue Oct 21, 2024 · 0 comments

Comments

@AsgerKrllAnd
Copy link

AsgerKrllAnd commented Oct 21, 2024

Hi

I have been looking through the code/documentation to see if i am correct in assuming there is no way to see hinges added in the structure. And i have found nothing.

With hinges i mean something like: ss.add_element(location=[[0, 0],[0, height]], spring={2:0}, g=column_self_weight)

and a plot like this:
image

Is this intentional, or a feature that might be added later?

Am considering adding it myself via pull request, but i fear i might be in over my head.

Has anyone solved it "outside" anastruct with just matplotlib maybe?

Edit:

I solved it for my case with adding a spring parameter to a node counter i already had in place.

Node counter:

def _add_node(self, x, y, node_id, node_ids, spring=False):
        node_id += 1
        node_ids.append({'id': node_id, 'node': x, 'y': y, 'spring': spring})
        return node_id, node_ids

Hinge visual:

for node in node_ids:
    if node['spring']:
        x, y = node['node'], node['y']
        plt.scatter(x, y, s=100, color='white', edgecolors='black', linewidths=2, zorder=5)

# Get the current figure object
fig = plt.gcf()

# Convert the figure to SVG and return it
return ImageResult(file_to_svg(fig))

Result is:
image

@AsgerKrllAnd AsgerKrllAnd changed the title spring/hinge visual in plots Spring/hinge visual in plots Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant