part file names

Having problems with or questions about SheetCam? Post them here.
Post Reply
bcorley
Posts: 14
Joined: Mon Apr 27, 2020 3:47 pm

part file names

Post by bcorley »

Les,
I'm attempting to make an enhanced Autoload plugin that will iterate through each part in the Parts tree and compare its filename to the one detected. If it's a match, then, select the part, else, add a new part to the list, select it, then do the LoadDrawing operation.

Can you give me the syntax for the part filename property?
User avatar
Les Newell
Site Admin
Posts: 3668
Joined: Thu May 11, 2006 8:12 pm

Re: part file names

Post by Les Newell »

Parts don't always include the drawing file name (e.g a copy won't) but something like this should work:

Code: Select all

function LoadFile(fileName)
   local parts = sc.Parts:Get()
   for idx=0, parts:GetCount() -1 do
      local part = parts:op_index(idx)
      if fileName == part:GetFileName() and not part:IsDuplicate() then
         parts.Selected:Set(part)
         part:Load(fileName)
         return
      end
   end
   local part = parts:AddNew()
   part:Load(fileName)
end
Post Reply