This works well so far and avoids the insertion of unnecessary layers.
I only have one problem with it - if you want to undo it, you have to undo every single step, it doesn’t behave like a single command, even if it looks like one because of the echo off at the beginning.
That’s a real bummer.
I had hoped that it could be summarized somehow.
Is there a simple way to convert this into a script to which the address and file name are passed as variables in order to have one script for all parts?
That sounds very promising.
I’ve already tried to get the AI to help me with this.
This is what came out of it:
Option Explicit
Sub LoadPartFromFile(filePath As String, fileName As String)
' Turn off command echo
Call Rhino.Command("_EchoOff", 0)
' Import the part
Call Rhino.Command("-_Import " & filePath & fileName, 0)
' Change imported objects to the current layer
Call Rhino.Command("_ChangeToCurrentLayer", 0)
' Set the layer explicitly to avoid creating new layers
Call Rhino.Command("_-Layer _Name library _Enter", 0)
' Turn command echo back on
Call Rhino.Command("_EchoOn", 0)
End Sub
' Example usage:
' You would call this from Rhino's command line or another script like this:
' Call LoadPartFromFile("R:\Bibliothek\Schrauben\M8_Innensechskant\", "30.3dm")
Unfortunately, the debugging efforts came to nothing.
Can anyone here help me further, I am still a total novice when it comes to programming and implementation.
Option Explicit
' Globale Variable, um den Pfad zu speichern
Dim globalFullPath
Sub SetPath(path)
globalFullPath = path
End Sub
Sub LoadPartFromFile
' Importieren Sie das Teil
Rhino.Command "-_Import " & globalFullPath, 0
' Ändern Sie die importierten Objekte auf die aktuelle Ebene
Rhino.Command "_ChangeToCurrentLayer", 0
' Löschen Sie die Ebene library
Rhino.Command "_-Layer _Delete ---library--- _Enter", 0
End Sub
Certainly not the most elegant variant, but passing variables directly led to all sorts of dead ends.
The structure of the script also looks a bit weird to me as a layman.