Hi,
I’m exporting an NSC file as a STP, and it creates the bodies and labels them by object number. Does anyone know of a way to automatically set the comment of the object as the object label in the STP file?
Hi,
I’m exporting an NSC file as a STP, and it creates the bodies and labels them by object number. Does anyone know of a way to automatically set the comment of the object as the object label in the STP file?
I’m not sure I understand your issue, it might help if you detail how you perform the export.
Based on what I understand of your question, I think you could achieve what you want with a ZPL macro or the ZOSAPI, but I’ll show the macro here.
# Number of Objects in the NDE
number_of_objects = NOBJ(1)
# Static parameters of EXPORTCAD (more details in Help File)
VEC1(1) = 1 # STEP file format
# Loop over the objects
FOR object_id, 1, number_of_objects, 1
# Extract current object comment
temp = NPRO(1, object_id, 1, 0)
comment$ = $BUFFER()
# Create a file name based on the object comment
step_file_name$ = "D:\" + comment$ + ".STP"
# Adjust the first and last objects of EXPORTCAD (more details in the Help File)
VEC1(3) = object_id
VEC1(4) = object_id
# Export a CAD of the current object
EXPORTCAD step_file_name$
NEXT
Hopefully the code is self-explanatory. Note this method of extracting the non-sequential comments:
This is the result:
I hope this helps.
Take care,
David
I’m not sure I understand your issue, it might help if you detail how you perform the export.
Based on what I understand of your question, I think you could achieve what you want with a ZPL macro or the ZOSAPI, but I’ll show the macro here.
# Number of Objects in the NDE
number_of_objects = NOBJ(1)
# Static parameters of EXPORTCAD (more details in Help File)
VEC1(1) = 1 # STEP file format
# Loop over the objects
FOR object_id, 1, number_of_objects, 1
# Extract current object comment
temp = NPRO(1, object_id, 1, 0)
comment$ = $BUFFER()
# Create a file name based on the object comment
step_file_name$ = "D:\" + comment$ + ".STP"
# Adjust the first and last objects of EXPORTCAD (more details in the Help File)
VEC1(3) = object_id
VEC1(4) = object_id
# Export a CAD of the current object
EXPORTCAD step_file_name$
NEXT
Hopefully the code is self-explanatory. Note this method of extracting the non-sequential comments:
This is the result:
I hope this helps.
Take care,
David
Hi,
Thank you for the response, but unfortunately not what I meant. I have a system file with multiple objects, and I export the entire system as a single CAD for the mechanics team to build around. The question is whether there is a way to export the system along with object labels in a single STP file...
Unfortunately, I don’t think OpticStudio (OS) can do that. It seems like you could do it programmatically by modifying the STEP file itself, but I’m not familiar with the syntax of STEP files.
For your reference this is what I tested:
SPHERE1
This is why I think it should be possible, but would require knowledge of the STEP syntax. Since the object seem to appear in the STEP file in the same order as in the NDE, you could use a script to parse the comments of the NDE and add those PRODUCT
entities to the step file somehow.
Sorry I cannot help further and take care,
David
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.