Macro to automate drawing an object and intersection of members

Macro to automate drawing an object and intersection of members

bos3UYUJ
Contributor Contributor
505 Views
2 Replies
Message 1 of 3

Macro to automate drawing an object and intersection of members

bos3UYUJ
Contributor
Contributor

Good afternoon,

 

I'm looking to write a VBA macro which interfaces with the ROBOT API to perform the following tasks:

- Draw an object of a chosen dimension and location in my model (either a square or circle)

- Change the object to members by clicking 'discretization'

- Find the intersection of the new object's members with the existing model's members

- Create new members at the intersections

- Output the length of the new members

 

I have attached a photograph to help demonstrate the steps that I am looking to automate. Can you please let me know if this is possible and if you have any similar examples already written?

 

Many thanks

ROBOT Forum Question.png

0 Likes
506 Views
2 Replies
Replies (2)
Message 2 of 3

Stephane.kapetanovic
Mentor
Mentor

hi @bos3UYUJ 

What you are asking involves creating bars and nodes. To get started, you can search this forum for code examples using keywords such as "API Nodes," "API Create," and similar topics.

For the intersections of your rectangle with existing bars, you will need to look into resources from forums dedicated to 3D geometric algorithms. Specifically, you should focus on methods for intersecting a polygon with a line segment, or one bar with another. Once you have that, you can loop through the elements in the region of interest and split your bars at each intersection you encounter.

Depending on your case, you might be able to simplify the process to just a few bars, or, if your geometry is well defined, loop only through the expected elements.

Also note that it is possible to create intersections by adding nodes without necessarily segmenting the bars.

Create nodes API(API) Lines to bars converter addin(API) addin for creating clossest nodes between barsHow to know if a line intersects a rectangleMacro Autocad to Robot (API)

Depending on the size of your model and the number of rectangles you want to insert, programming the process can range from straightforward to quite time-consuming, both in terms of coding effort and execution time.

An alternative approach is to use a DWG background: simply copy the rectangles manually by aligning them with the background, or copy and paste them from one model to another. You can then apply a global intersection to finalize the process.

Best regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
Message 3 of 3

bos3UYUJ
Contributor
Contributor

Hi @Stephane.kapetanovic,

 

Thank you for your quick and very helpful reply. I have to replicate this process many many times so it will be advantageous to script it.

I will start creating the macro now using the links you shared as inspiration.

 

Best wishes

0 Likes