(API) Create Cladding from coordinatres

(API) Create Cladding from coordinatres

Anonymous
Not applicable
1,789 Views
15 Replies
Message 1 of 16

(API) Create Cladding from coordinatres

Anonymous
Not applicable

Hello, 

 

I am trying to develop a macro in order to create a cladding from coordinates. 

When I execute this maccro, an error page appears indicating: "Objet requis".

 

Here is the macro: 

 

 

Sub Create_cladding()


Dim monobjet As RobotObjObject
Dim moncontour As New RobotGeoContour
Dim monsegment() As New RobotGeoSegmentLine



Dim i As Long

ReDim monsegment(1 To 4)

monsegment(1).P1.Set 0, 0, 0
moncontour.Add monsegment(1)
monsegment(2).P1.Set 1, 0, 0
moncontour.Add monsegment(2)
monsegment(3).P1.Set 1, 1, 0
moncontour.Add monsegment(3)
monsegment(4).P1.Set 0, 1, 0
moncontour.Add monsegment(4)

moncontour.Initialize


Set monobjet = robapp.Project.Structure.Objects.Create(1)
monobjet.Main.Geometry = moncontour
monobjet.Main.Attribs.Meshed = False
monobjet.Main.Attribs.DirZ = 0 ' axe local
monobjet.Main.Attribs.SetDirX I_OLXDDT_CARTESIAN, 1, 0, 0 


monobjet.Initialize 
monobjet.Update 

moncontour.Clear

Set monobjet = Nothing
Set moncontour = Nothing
ReDim monsegment(1 To 1)
Set monsegment(1) = Nothing

 

End Sub

 

Thank you for your help!

 

Erwann

0 Likes
Accepted solutions (1)
1,790 Views
15 Replies
Replies (15)
Message 2 of 16

Rafal.Gaweda
Autodesk Support
Autodesk Support
Accepted solution

Hi Erwann,

 

 

Your code creates Contour (Object).

You need to apply Cladding Label to this Object

 

Example code below

 


RobApp.Project.Structure.Objects.Get(obj_number).SetLabel I_LT_CLADDING, "Two-way"

 

In French "Two-way" is "Deux directions" 🙂



Rafal Gaweda
Message 3 of 16

daniilZSZ8N
Participant
Participant

Hi Rafal,
Working in Python sandbox 2.6

I'm trying to apply meshing to the contour in Robot but it isn't working
Everything else is working fine, labels,etc, just can't convert a contour to the analytic panel.

 

app = RobotApplicationClass()
project = app.Project
structure = project.Structure
labels = structure.Labels
loads = structure.Cases
ProjectPrefs = project.Preferences
bars = structure.Bars
objects = structure.Objects
nodes = structure.Nodes

fn = objects.FreeNumber

points = app.CmpntFactory.Create(IRobotComponentType.I_CT_POINTS_ARRAY)
points.SetSize(4)
points.Set(1,0,0,0)
points.Set(2,1,0,0)
points.Set(3,1,1,0)
points.Set(4,0,1,0)

objects.CreateContour(fn, points)
ro = objects.Get(fn)
ro.Main.Attribs.Meshed = True
ro.SetLabel(IRobotLabelType.I_LT_CLADDING, "Two-way")

 

 

0 Likes
Message 4 of 16

Rafal.Gaweda
Autodesk Support
Autodesk Support

Hi @daniilZSZ8N 

 

You have to decide whether You want to have panel (meshed) or cladding.

Last command is to create cladding.



Rafal Gaweda
0 Likes
Message 5 of 16

daniilZSZ8N
Participant
Participant

Oh, yes, I just wanted to say that none of them are working.
I tried the way described officially here https://knowledge.autodesk.com/support/robot-structural-analysis-products/learn-explore/caas/sfdcart...

and your code with selecting by type and converting in a loop.
Nothing. Still contour.
Can it be the Robot 2020 API issue?

0 Likes
Message 6 of 16

daniilZSZ8N
Participant
Participant

Boom!

The answer is 

objects.CreateContour(fn, points)
ro = objects.Get(fn)
ro.Initialize()
ro.SetLabel(IRobotLabelType.I_LT_CLADDING, "Two-way")
ro.Update()

 
 
 
 
 
Message 7 of 16

Rafal.Gaweda
Autodesk Support
Autodesk Support

Hi @daniilZSZ8N 

 

It has nothing to do with meshing 🙂

 



Rafal Gaweda
0 Likes
Message 8 of 16

durducgeorge
Contributor
Contributor

Hello,

 

 

when i try to convert the contour into cladding, it doesn't work (I tried in C#, maybe in vba it works)

RobApp.Project.Structure.Objects.Get(obj_number).SetLabel I_LT_CLADDING, "Two-way"

 

0 Likes
Message 9 of 16

Stephane.kapetanovic
Mentor
Mentor

hi @durducgeorge 

try this

Sub AssignCladdingDiectionToContour()
  Dim RobApp As IRobotApplication: If NotReady(RobApp) Then Exit Sub

  Dim obj As RobotObjObject
  Set obj = RobApp.Project.Structure.Objects.Get(obj_number)
  obj.SetLabel I_LT_CLADDING, "Direction X"
  obj.Update

  RobApp.Project.ViewMngr.Refresh

  Set RobApp = Nothing
End Sub
RobotApplication RobApp = new RobotApplication();
RobotObjObject obj = (RobotObjObject)RobApp.Project.Structure.Objects.Get(obj_number);
obj.SetLabel(IRobotLabelType.I_LT_CLADDING, "Direction Y");
obj.Update();
RobApp.Project.ViewMngr.Refresh();

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 10 of 16

durducgeorge
Contributor
Contributor

Hello S.Kapetanovic,

 

Thank you! It works!

 

 

Message 11 of 16

heau_a
Explorer
Explorer

Hello Mr.kapetanovic,

 

I'm reaching you regarding an issue that I encoutered when I tried to apply claddings to some coordinates from a CSV file. Explaining from scratch, I have a csv file with lines giving id type and coordinates of each pieces and as a test we assume that they were all claddings. The goal was to transform it as a list of sublists of each materials and apply the claddings on each. Therefore, I used Dynamo in Robot directly to try Python Scripts but I had so many problems with RobotOM and class usage. I don't know if the best option is to create directly a Robot Add-On or to try again via Dynamo Python and instanciate a new Robot cause I saw on internet that it was impossible to save an old instance of Robot and that we were forced to do RobotApplicationClass(). 

 

I can give you an example of my code so you can analyse me errors for now and tell me what could be improved cause actually I have a lot of problems and tried a lot of things to make it work. 

import clr
clr.AddReference('Interop.RobotOM')
import RobotOM
import time

# Entrée : liste de claddings sous forme [ID, label, x1, y1, z1, x2, y2, z2, ..., xn, yn, zn]
liste_claddings = IN[0]

# Nouvelle instance de Robot
robot = RobotOM.RobotApplicationClass()
robot.Visible = True
robot.Project.New(RobotOM.IRobotProjectType.I_PT_FRAME_3D)
time.sleep(0.5)

structure = robot.Project.Structure
objects = structure.Objects
factory = robot.CmpntFactory

results = []

def get_free_object_id(start=1):
    free_id = start
    while True:
        try:
            if objects.Get(free_id):
                free_id += 1
            else:
                return free_id
        except:
            return free_id

for ligne in liste_claddings:
    try:
        ID = int(ligne[0])
        nom = ligne[1]
        coords = ligne[2:]

        if len(coords) < 9 or len(coords) % 3 != 0:
            results.append(f"Cladding {ID} ignoré : mauvais nombre de coordonnées")
            continue

        nb_pts = len(coords) // 3
        pts = factory.Create(RobotOM.IRobotComponentType.I_CT_POINTS_ARRAY)
        pts.SetSize(nb_pts)

        for i in range(nb_pts):
            x, y, z = coords[i*3], coords[i*3+1], coords[i*3+2]
            pts.Set(i + 1, x, y, z)

        obj_id = get_free_object_id(ID)
        objects.CreateContour(obj_id, pts)

        obj = objects.Get(obj_id)
        if nom and structure.Labels.IsAvailable(RobotOM.IRobotLabelType.I_LT_CLADDING, nom):
            obj.SetLabel(RobotOM.IRobotLabelType.I_LT_CLADDING, nom)
        obj.Update()

        results.append(f"Cladding {ID} créé")
    except Exception as e:
        results.append(f"Erreur cladding {ligne[0]} : {str(e)}")

OUT = results

This code may seem good but after the execution I'm gonna have the error "Unable to find reference interop robot om " even I have the dll file and after fixed it they say the SetSize is not usable for this class object. 

 

Thank you in advance,

M.G

0 Likes
Message 12 of 16

Stephane.kapetanovic
Mentor
Mentor

hi @heau_a 

Have you tried looking at more specialized forums focused on Python and Dynamo? 

Please note that this forum is not intended for troubleshooting or support related to software installation and system configuration.

The issue you're encountering ('Unable to find reference interop RobotOM') is not directly related to the API itself, but most likely stems from how the RobotOM library is linked or registered within your development environment, particularly the integration between Python, Dynamo, and your IDE.

Make sure the RobotOM COM library is properly registered and accessible from your scripting environment. 

Also, ensure that the Robot installation path is either included in your system PATH environment variable or explicitly added within your script before attempting to load the COM object.

However, you will find several threads here discussing Python, such as which version to use, common issues with COM type casting in Python, and even some complete working scripts.

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
0 Likes
Message 13 of 16

heau_a
Explorer
Explorer

Yes already try this forum, two topics of 2018 and 2022 without any response...

We also think that it could be due to Dynamo link with Robot and will try SDK addin instead.

Thank you !

0 Likes
Message 14 of 16

Stephane.kapetanovic
Mentor
Mentor

hi @heau_a 

I don’t know your industry well, but what you’re doing is quite simple from a programming point of view. However, the chosen approach may introduce unnecessary complexity. While the example code can help you understand how Dynamo works, it’s worth evaluating whether this setup is truly the most efficient for your goals.

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
0 Likes
Message 15 of 16

heau_a
Explorer
Explorer

Hello,

 

I'm reaching you cause I've been programming an Add-In recently for a purpose and everything was working well before I decided to change the name from MyAddin to my custom name. The fact is that I thought everything will be fine I could just delete one and install the new one with the different name. But, since I did that when I add the new one I have 2 add-in with some japanese characters. The fact is one is blocked I can't do anything and the other one is linked, as you can see in the photo but I have my function but it's not usable. 

heau_a_0-1750952911960.png

 

So yeah I'm a bit upset cause I shouldn't change the name and I saw on some posts that it was an option with the regedit that saved the old addins names and GUID. I did everything trying to delete old GUID Assembly Keys and assign a new one but nothing changed. 

0 Likes
Message 16 of 16

Stephane.kapetanovic
Mentor
Mentor

hi @heau_a 

the issue you're encountering is unfortunately completely unfamiliar to me. For an unexpected issue that occurred following a recommended automated procedure after forcing an add-in into the Windows registry and renaming it, Autodesk Support will be best placed to assist you.

If this situation were more common, I’d suggest removing all existing shortcuts and recreating them manually, verifying each one works correctly. Add-ins Manager Dialog Box

By the way, we favor a portable architecture for our free standalone executables, meaning no system integration, no third-party dependencies, and no installation required.

I sincerely hope you're able to find a solution quickly.  

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
0 Likes