API -- Change dimension in part without opening it?

What I want to do is locate a part file on the system by name, including folder, save that under a new name, and with that newly saved part, change a dimension and save it, without opening anything. Then I want to locate a drawing file on the system by name, save it under a new name, and assign the newly saved part file to it as the reference. Is this possible? If so, how do I get started? I can get this to work if the parts and drawings are opened, and I can open them with API, but I want to go further and do it without opening them in the first place, to make the process go faster. Thank You,

-plh

Reply to
plh
Loading thread data ...

I can tell you why you might not want to do this. If you change the dimension without rebuilding and saving the drawing will open in SWViewer with the old dimension even though you have given it a new filename. I have seen this kind of thing get to mfg. It ain't pretty.

Reply to
TOP

I am aware of that limitation, thanks. What I am going to do is bring the drawing up (in SW) *after* A have done all the "silent" changes, it will rebuild then (see original post) Thanx,

-plh

Reply to
plh

limitation, thanks. What I am going to do is bring the

You can do all this EXCEPT change the dimension while files are closed. There might be a somewhat clumsy work-around if you built your parts to include an externally linked design table, or a macro feature that would read a dimension from custom properties or other external source each time the part rebuilds. Short of extraordinary measures like these, however, a dimensional change would necessitate a file-open on the part or assembly model (not necessarily the drawing that references them).

HTH, BDB

Reply to
customsolids

True enough. Still requires a file-open, which takes some time.

Reply to
customsolids

True enough. Still requires a file-open, which takes some time.

Reply to
customsolids

Of course with SW saying you have the file open is a relative term. Just how open does it have to be? For example if you write directly to database or turn off visibility you minimize overhead related to interactive use while still capturing the important stuff.

snipped-for-privacy@yahoo.com wrote:

Reply to
TOP

In article , snipped-for-privacy@yahoo.com says...

Hi, I have not looked at this thread in a while. The whole point of this project is to programatically clone parts with different "driver" dimensions with the end result of rapidly produced and consistent drawings. I am resigned to opening the drawings and parts. I now have the following sequence pretty good: Copy "base" drawing to new name. (using FileSystemObject) Open new drawing (Opendoc6) Open base part (OpenDoc6) Save base part under new name. (swModelDocExt.SaveAs)This causes to the drawing to refer to the correct part. The problem is that at the save as routine closes the part. I want to leave it open so that I can go in and programatically change the relevant dimension. I tried to reopen it (OpenDoc6) but nWarnings is returning 128 (& as of this time I don't know what that means) and I end up with the Drawing open, referencing the correct part, but the part closed. So, that is my current problem, can I prevent swModelDocExt.SaveAs from closing the part. Thank You,

-plh

PS: bolRetVal = swApp.SetCurrentWorkingDirectory(strHomeFolder) Set obFSO = CreateObject("Scripting.FileSystemObject") With obFSO If .FileExists(Me.txtFolder.Value & "\" & Me.txtPartNumber.Value & ".SLDPRT") _ Or .FileExists(Me.txtFolder.Value & "\" & Me.txtPartNumber.Value & ".SLDDRW") Then 'in case of overwrite make sure user wants to do that If MsgBox("File Exists! Want to Overwrite?", vbYesNo) 6 Then Me.txtFolder.Value = "" Me.txtPartNumber.Value = "" Exit Sub Else '.CopyFile strBasePart, Me.txtFolder.Value _ '& "\" & Me.txtPartNumber.Value & ".SLDPRT" 'copy the part to that folder .CopyFile strBaseDrawing, Me.txtFolder.Value _ & "\" & Me.txtPartNumber.Value & ".SLDDRW" 'copy the drawing to that folder End If Else .CopyFile strBaseDrawing, Me.txtFolder.Value _ & "\" & Me.txtPartNumber.Value & ".SLDDRW" 'copy the drawing to that folder End If End With strPartToReference = Me.txtFolder.Value & "\" & Me.txtPartNumber.Value & ".SLDPRT" 'Me.txtFolder.Value & "\" & Me.txtPartNumber.Value & ".SLDPRT" strDrawingToOpen = Me.txtFolder.Value & "\" & Me.txtPartNumber.Value & ".SLDDRW" Set swDrawing = swApp.OpenDoc6(strDrawingToOpen, swDocDRAWING, _ swOpenDocOptions_Silent, "", nErrors, nWarnings) If ReportNErrors(nErrors, nWarnings, strDrawingToOpen) = False Then Exit Sub 'open the New drawing which will still reference the BASE part Set swPart = swApp.OpenDoc6(strBasePart, swDocPART, _ swOpenDocOptions_Silent, "", nErrors, nWarnings) If ReportNErrors(nErrors, nWarnings, strBasePart) = False Then Exit Sub 'open the BASE part bolRetVal = swApp.SetCurrentWorkingDirectory(Me.txtFolder.Value) Set swModelDocExt = swPart.Extension bolRetVal = swModelDocExt.SaveAs(strPartToReference, 0, swSaveAsOptions_Silent, Nothing, nErrors, nWarnings) If ReportNErrors(nErrors, nWarnings, strPartToReference) = False Then Exit Sub 'do a save as in order to link the new part to th drawing Set swPart = swApp.OpenDoc6(strPartToReference, swDocPART, _ 0, "", nErrors, nWarnings) If ReportNErrors(nErrors, nWarnings, strPartToReference) = False Then Exit Sub 'open the NEW part Set swPart = swApp.ActivateDoc2(strPartToReference, False, longstatus)

Reply to
plh

I was able to solve this by opening the part first then the drawing. For some reason that did it.

-plh

Reply to
plh

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.