青华模具培训学校

 找回密码
 注册

QQ登录

只需一步,快速开始

青华模具培训学院
查看: 2002|回复: 6

[疑难] 用C#语言编写一个调用装配图各零件装配关系的程序

  [复制链接]
发表于 2014-9-25 10:31 | 显示全部楼层 |阅读模式
悬赏200G币已解决
小弟急需做一个用C#语言对ug二次开发的程序,目标是从UG数据库调出装配图各个零件的装配关系,求各位大侠帮着编个程序,谢谢了6 _, l) q, R2 u9 b/ g4 F

最佳答案

查看完整内容

public class AssmTree (){ private static Session theSession; private static UI theUI; private static UFSession theUfSession; private static ListingWindow listwindow; private static Form AssmTreeForm; private static TreeView PartTree; public AssmTree() { theSession = Session.GetSession(); theUI ...
发表于 2014-9-25 10:31 | 显示全部楼层
本帖最后由 danyfer 于 2014-10-17 21:26 编辑
0 y/ L: z" B2 Y, W0 c  }. l. F. U$ W/ ?
public class  AssmTree (){              private static Session theSession;
; O+ C" Q) s3 o+ U% p& ~        private static UI theUI;' F( [( d/ |6 ^6 v
        private static UFSession theUfSession;0 m# j8 N  H1 R) E
        private static ListingWindow listwindow;. |) P( @% e2 k" W* C

+ ~; h9 Y% L. K, l! C        private static Form AssmTreeForm;
4 ^# q! c2 U2 `' p$ V        private static TreeView PartTree;' d( P% _9 Q3 d& X! O

* R* H2 D4 o' x" l% a        
- o$ `# y' q2 Z0 A  ^6 Y        public AssmTree()) [9 k# c: {+ R1 F! R: I  ~+ N* X5 E
        {
/ ^2 q8 d2 O9 O            theSession = Session.GetSession();- \3 P/ \* G5 `5 F* x
            theUI = UI.GetUI();+ P  J- a& q' J
            theUfSession = UFSession.GetUFSession();, `9 t1 k2 V9 E  e# i1 Y* h3 _
            listwindow = theSession.ListingWindow;6 k8 o. S! X$ Z9 n
            listwindow.Open();           
2 \3 N# h( }- B% V) j
' j8 c5 O$ W* P' S            AssmTreeForm = new Form();
! N& S: ^6 N5 m2 i9 _
& P4 t: ?$ ^) X+ o0 u0 t            PartTree = new TreeView();/ _; m; m5 K: V% d
            PartTree.Parent = AssmTreeForm;
( x# J3 K9 R6 W/ z4 }& z3 I! u            PartTree.Dock = DockStyle.Fill;
. ?% j- @1 }) V        }; g3 f& k9 ?7 E# X- ~' ~3 ]
public void GetAssmPartTree()
+ ]  j; L' g  S3 R0 V        {
/ y1 J  z' p5 m2 q" S            NXOpen.Assemblies.Component rootComponent = theSession.Parts.Work.ComponentAssembly.RootComponent;& {2 \) H$ z/ G" ~
            
1 e' O: b' t# z6 T+ J" a            TreeNode parentNode = new TreeNode() ;
- p8 p( f4 Y% b( D7 j3 y. \: H            parentNode.Name = rootComponent.JournalIdentifier;6 u. F' t% n6 X3 n8 h* A  ]7 x
            parentNode.Text = rootComponent.DisplayName;
! c+ V; @2 p, P8 w% M            $ i+ O, w9 f& i
            PartTree.Nodes.Add(parentNode);
+ I/ {5 a9 z5 f3 ^1 [            getSubComponent(rootComponent, parentNode);
( h  [* `9 q9 U+ A, B6 u& k: O( O& e3 U3 ?
            AssmTreeForm.ShowDialog();
& [: O. n  o* F0 ]- a! z        }1 R& G9 U0 Y8 g, O2 d- X
' Q# B9 s! b" ]6 `' m/ B) c
        private static void getSubComponent(NXOpen.Assemblies.Component ParentComponent, TreeNode parentNode)
) r8 B7 B. t. J, w        {( g' ?  l0 o# p$ I
            NXOpen.Assemblies.Component[] sub_component = ParentComponent.GetChildren();
6 Y% n  w+ j* L, \            foreach (NXOpen.Assemblies.Component comp in sub_component)
4 d9 T. p  l, P$ ~            {
  u- R2 a6 z* H' @* e4 l7 _; J                TreeNode subNode = new TreeNode();
7 o. p4 x* j4 n9 p9 G1 A                subNode.Name = comp.JournalIdentifier;
* r# S  w7 r* O  L                subNode.Text = comp.DisplayName;. p  p. W( M4 [! M
                parentNode.Nodes.Add(subNode);
* v/ p7 M1 x7 c3 \                if (comp.GetChildren().Length > 0)
% U4 `9 z  f% X) P9 g                {9 y6 H& v; U. k& k
                    getSubComponent(comp, subNode);
  L" X! V; x+ N2 {( P2 s                }& @1 t/ Q7 K2 x  ^/ m4 f$ V) A
            }
7 P4 @% z+ H) _1 X" N3 l            ParentComponent.Blank();
! E( Q! E* o; I6 `& w            int sub_num = sub_component.Length;
3 Z: f% c4 U* Y$ y$ B$ o        }
2 ]7 S, C8 ?. `8 N: v+ Q}
) Z2 y7 ~9 O, Y  z
回复

使用道具 举报

发表于 2014-9-26 06:05 来自手机 | 显示全部楼层
支持一下…………
回复

使用道具 举报

 楼主| 发表于 2014-9-26 09:24 | 显示全部楼层
danyfer 发表于 2014-9-26 06:05
" B& U9 f$ G9 p( d" K, y支持一下…………

! s; a- n9 K7 y& V, ]5 z0 I/ }谢谢,能帮着编一个这样的程序吗?
3 V4 W6 @, T* V' I
回复

使用道具 举报

 楼主| 发表于 2014-10-3 19:42 | 显示全部楼层
danyfer 发表于 2014-9-29 13:18
% ^/ I9 q) d& `private static Session theSession;5 [" J# j9 k( T3 \
        private static UI theUI;
$ O6 k8 C0 k5 b2 b2 J) y2 Q        private static UFSessi ...

9 C7 t& `2 h+ {' q* D* h太感谢了,我试试
& A5 n6 V  R, c/ B
  @1 z6 ?( n/ U3 e" s1 H1 ]  R
回复

使用道具 举报

发表于 2014-10-23 21:49 | 显示全部楼层
楼主的话真如“大音希声扫阴翳”,犹如“拨开云雾见青天”,使我等网民看到了希望,看到了未来!
回复

使用道具 举报

发表于 2018-5-9 15:34 | 显示全部楼层
5555555555556666
回复

使用道具 举报

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

本版积分规则

QQ|关于我们|sitemap|小黑屋|Archiver|手机版|UG网-UG技术论坛-青华数控模具培训学校 ( 粤ICP备15108561号 )

GMT+8, 2025-7-12 16:50 , Processed in 0.137109 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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