几何尺寸与公差论坛

 找回密码
 注册
查看: 3346|回复: 4

1-354247171 - Automating cylinder creation in SW API

[复制链接]
发表于 2007-9-4 13:06:39 | 显示全部楼层 |阅读模式
ear Daniel,
Thank you for contacting SolidWorks API Support.
Please look at the method "AssemblyDoc::InsertNewPart2". Attached is a
macro which I have recorded to perform the cylinder creation operation
in the assembly.
In the macro, please put the path and filename for the new part in the
"InsertNewPart2" method.
I hope this helps.
Regards,
Pabitra
Pabitra Behera | API Support
www.solidworks.com | www.solidworks.com/api
Date Opened :   9/13/2006 05:18:46 AM
Summary :   Automating cylinder creation in SW API
Description :   Hi,

Is there a simply set of commands I can use to automate the creation of
a cylinder in an assembly? I am using VB 6.

Thanks.

Daniel Brown
Robotics Engineer
Accuray, Inc.
ACCURAY:  Enabling full-body radiosurgery using image-guided robotics
1310 Chesapeake Terrace
Sunnyvale, CA 94089
408-716-4600 x4830 (Office)
 楼主| 发表于 2007-9-4 13:07:28 | 显示全部楼层

回复: 1-354247171 - Automating cylinder creation in SW API

Hi Pabi,
Thanks for your recent help on automating the creation of cylinders in
SW.
I have another question in connection with the same project I'm working
on.
Basically, I'm trying to generate a number (as much as 150 in some
cases) of cylinders and insert them into an assembly, which in turn is
inserted into another assembly. The problem is that Sw complains that it
runs out of memory space at around the 30th cylinder even though I close
all the cylinder part files.
Is there a way I can turn off something (may be auto saving or whatever)
that can solve the problem? I must be able to insert all 150 *for
instance) into the assembly in one move. I am attaching a sample file
fyi. <<Trigem_G4_M_Path3.SLDPRT>>
Thanks in advance for your help
Daniel Brown
 楼主| 发表于 2007-9-4 13:08:00 | 显示全部楼层

回复: 1-354247171 - Automating cylinder creation in SW API

Hello Daniel,

Make sure to destroy all the object created inside the loop before you
go to process the next. As an example in VB:
  
   Set swFeature = Nothing
   Set swSketch = Nothing   etc.

This will help in releasing the memory.

Also you can use DoEvents function. Use this in between the major
operation like Opendoc, ForceRebuild, Or Save etc.(Please refer to the
DoEvents in MSDN for better understanding)

I hope this helps.

Regards,
Pabitra
 楼主| 发表于 2007-9-4 13:08:26 | 显示全部楼层

回复: 1-354247171 - Automating cylinder creation in SW API

Hi Pabi,

I tried all the suggestion you gave but I'm running into the same
problem. Will it make a difference if I suppressed on the previously
inserted cylinders before attempting to create and insert another one?

Thanks

Daniel Brown
 楼主| 发表于 2007-9-4 13:09:04 | 显示全部楼层

回复: 1-354247171 - Automating cylinder creation in SW API

Hi Daniel,

Definitely it will make a difference. A suppressed component is removed from memory, so loading speed, rebuild speed, and display performances are improved. Because of the reduced complexity, evaluation of remaining components occurs faster.

Also, you should look into “Work with Lightweight Components” (see API help file).

Regards,
Pabitra
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-23 00:00 , Processed in 0.038444 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表