import a 3d dwg to part
import a 3d dwg to part
Hey there,
I'm fairly VBA centric, but this one has me flummoxed.
I've got a butt load of old 3D dwg's that I got from KraftMaid years ago, which are cabinet models.
Way back yonder, I used SketchUp to design a kitchen, but I'm doing a new kitchen and want to use Swx.
I can't for the life of me figure out how to import a dwg into a part instead of a drawing or a sketch via the API.
I've got a nice macro for importing folders of step files and saving to SolidWork parts that I was leveraging for this, but SolidWorks is insistent on importing the dwg's either into drawings or sketches.
I can do this manually. I've tried recording a macro doing it and that's useless as running it again imports the dwg as a drawing.
Any thoughts?
Thanks
I'm fairly VBA centric, but this one has me flummoxed.
I've got a butt load of old 3D dwg's that I got from KraftMaid years ago, which are cabinet models.
Way back yonder, I used SketchUp to design a kitchen, but I'm doing a new kitchen and want to use Swx.
I can't for the life of me figure out how to import a dwg into a part instead of a drawing or a sketch via the API.
I've got a nice macro for importing folders of step files and saving to SolidWork parts that I was leveraging for this, but SolidWorks is insistent on importing the dwg's either into drawings or sketches.
I can do this manually. I've tried recording a macro doing it and that's useless as running it again imports the dwg as a drawing.
Any thoughts?
Thanks
chris
Re: import a 3d dwg to part
While in the part, select a plane for the sketch to be placed upon, and select "insert", then "DXF/DWG"
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
Re: import a 3d dwg to part
Not what I'm trying to do.
You can open a dxf/dwg from the dialog as a part by selecting that option.
Can't figure out how to do that programmatically.
You can open a dxf/dwg from the dialog as a part by selecting that option.
Can't figure out how to do that programmatically.
chris
Re: import a 3d dwg to part
Does this help at all? I know it isn't importing it the way you want, but it's a start. It's probably a matter of figuring out how to set the arguments.
https://help.solidworks.com/2017/englis ... ple_VB.htm
https://help.solidworks.com/2017/englis ... file4.html
https://help.solidworks.com/2017/englis ... gData.html
Looking through those links, it doesn't look like what you want is an option.
https://help.solidworks.com/2017/englis ... ple_VB.htm
https://help.solidworks.com/2017/englis ... file4.html
https://help.solidworks.com/2017/englis ... gData.html
Looking through those links, it doesn't look like what you want is an option.
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
Re: import a 3d dwg to part
I was going to suggest the same thing, but I tried it out and it puts all the entities into a sketch for any argument that applies to a part file. I'm not sure of a way to get it to convert the dxf into curve features.SPerman wrote: ↑Thu Jul 14, 2022 6:38 pm Does this help at all? I know it isn't importing it the way you want, but it's a start. It's probably a matter of figuring out how to set the arguments.
https://help.solidworks.com/2017/englis ... ple_VB.htm
https://help.solidworks.com/2017/englis ... file4.html
https://help.solidworks.com/2017/englis ... gData.html
Looking through those links, it doesn't look like what you want is an option.
image.png
Re: import a 3d dwg to part
Okay,
I've dug through the API doc's with limited/no success.
Here's what I'm trying to automate:
1) Open a dwg file:
2) Select the "import to new part as: 3D curves or model"
3) Choose the correct settings:
4) and Voila!, part:
If I do a macro record of this, which then looks like this:
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
boolstatus = swApp.LoadFile2("V:\Engineering\Mechanical\Models\KraftMaid\Office\CAD_DKD362D.dwg", "0 0")
Set Part = swApp.ActiveDoc
End Sub
This is the end result:
Definitely not what I'm looking for.
I've played around with this code:
Sub main()
Dim swApp As SldWorks.SldWorks
Dim filename As String
Dim longerrors As Long
Dim retVal As Boolean
Dim importData As SldWorks.ImportDxfDwgData
filename = "V:\Engineering\Mechanical\Models\KraftMaid\Base Cabinets\CAD_BPPSFCC3627.dwg"
Set swApp = Application.SldWorks
Set importData = swApp.GetImportFileData(filename)
importData.ImportMethod("") = SwConst.swImportModelItemsFromEntireModel
Dim newDoc As SldWorks.ModelDoc2
Set newDoc = swApp.LoadFile4(filename, "r", importData, longerrors)
End Sub
The problem is there are about eleventy-seven options for the import method and the import data values.
I've tried a bunch of them with no success. Some do nothing at all, some open the file as a drawing.
Any ideas?
Thanks,
I've dug through the API doc's with limited/no success.
Here's what I'm trying to automate:
1) Open a dwg file:
2) Select the "import to new part as: 3D curves or model"
3) Choose the correct settings:
4) and Voila!, part:
If I do a macro record of this, which then looks like this:
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
boolstatus = swApp.LoadFile2("V:\Engineering\Mechanical\Models\KraftMaid\Office\CAD_DKD362D.dwg", "0 0")
Set Part = swApp.ActiveDoc
End Sub
This is the end result:
Definitely not what I'm looking for.
I've played around with this code:
Sub main()
Dim swApp As SldWorks.SldWorks
Dim filename As String
Dim longerrors As Long
Dim retVal As Boolean
Dim importData As SldWorks.ImportDxfDwgData
filename = "V:\Engineering\Mechanical\Models\KraftMaid\Base Cabinets\CAD_BPPSFCC3627.dwg"
Set swApp = Application.SldWorks
Set importData = swApp.GetImportFileData(filename)
importData.ImportMethod("") = SwConst.swImportModelItemsFromEntireModel
Dim newDoc As SldWorks.ModelDoc2
Set newDoc = swApp.LoadFile4(filename, "r", importData, longerrors)
End Sub
The problem is there are about eleventy-seven options for the import method and the import data values.
I've tried a bunch of them with no success. Some do nothing at all, some open the file as a drawing.
Any ideas?
Thanks,
chris
Re: import a 3d dwg to part
Wow, just wow. Just for fun, I went over to the SolidWorks user forum to see if I could find anything there.
That's friggen useless. No topic segregation so everything just get jammed together. The chances of finding anything are remote, and I suspect any message asking for assistance is going to get lost in the noise.
So, I filed a support request. That's 2 in 2 days! I'm on a roll....
That's friggen useless. No topic segregation so everything just get jammed together. The chances of finding anything are remote, and I suspect any message asking for assistance is going to get lost in the noise.
So, I filed a support request. That's 2 in 2 days! I'm on a roll....
chris
- AlexLachance
- Posts: 2195
- Joined: Thu Mar 11, 2021 8:14 am
- Location: Quebec
- x 2382
- x 2021
Re: import a 3d dwg to part
@josh might be of help. He's like THE reference in these type of things
Do you have an example model we could use to try it on our end..? Maybe your issue is version dependant..?
Do you have an example model we could use to try it on our end..? Maybe your issue is version dependant..?
Re: import a 3d dwg to part
Mod's, would you please move this discussion to "API"?
I put this in the wrong place.
Thanks in advance
I put this in the wrong place.
Thanks in advance
chris