青华模具培训学校

 找回密码
 注册

QQ登录

只需一步,快速开始

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

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

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

最佳答案

查看完整内容

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 编辑 , F1 x, M4 g' v- j1 T  E. L! X+ `
4 O- l7 V/ ?5 |# s5 t
public class  AssmTree (){              private static Session theSession;
% T3 }! q+ J! v0 t* z6 E0 ~; A2 X0 D        private static UI theUI;. M5 A+ ?; k9 y: p
        private static UFSession theUfSession;% A' m4 D. j3 @5 t, ?. {. \
        private static ListingWindow listwindow;( `3 Q: u. K% R# b  j
" d2 Y4 f4 b  Z8 a" e
        private static Form AssmTreeForm;
: w# F6 e, x& ?, s        private static TreeView PartTree;) V0 ^: b- l+ q& @* w
' _6 t( M$ Y/ H" [6 }
        5 T: A) m3 [$ j- W- [7 b
        public AssmTree()0 F/ ]5 G& u" \
        {' R. \9 K3 K2 {" O
            theSession = Session.GetSession();
9 U+ Z0 i% Q* D6 d9 }* h            theUI = UI.GetUI();
" ]$ K5 W5 ^/ b/ y: k. g            theUfSession = UFSession.GetUFSession();
. H' }' W. e" u1 M. U* p            listwindow = theSession.ListingWindow;$ C% _6 G" p, I/ g  [4 W3 |
            listwindow.Open();           9 ^* [- H( }& a7 E

5 s5 u0 b0 k) f( ~            AssmTreeForm = new Form();  Q9 {8 N9 v0 j( H& M) J9 l
' k! V2 x% J9 s9 ~: L! W
            PartTree = new TreeView();9 a0 H( Q8 f% h: U9 N/ Y
            PartTree.Parent = AssmTreeForm;1 _" N! y% `1 P# C+ E% W
            PartTree.Dock = DockStyle.Fill;* f  W. m8 i, x' _. M, k6 G* n% b
        }
& {$ D7 s  s# E, A' O& f8 Z" E  h: {public void GetAssmPartTree()
7 o1 `, j( W4 J  J, f        {' L; a+ f+ Q1 l6 A2 G
            NXOpen.Assemblies.Component rootComponent = theSession.Parts.Work.ComponentAssembly.RootComponent;
! j0 u" R6 z* `0 m$ d/ Y            
1 b$ w! g1 _! p" Q; b9 u            TreeNode parentNode = new TreeNode() ;
5 a9 d6 H0 H. z' `; U  K            parentNode.Name = rootComponent.JournalIdentifier;
3 g& V/ V* {* |            parentNode.Text = rootComponent.DisplayName;
2 d, l% @0 W$ u8 v8 S: ?# L            ; k& |/ Y# x% N( x. d- B
            PartTree.Nodes.Add(parentNode);$ Q( |$ V9 l# v( B. ~1 \: x+ k
            getSubComponent(rootComponent, parentNode);' e2 g' N# z4 [4 F
9 _2 ~: E* j, @, M
            AssmTreeForm.ShowDialog();" z- U( L5 Q5 e9 ~5 d! S# h' x
        }
$ m) {& i7 v  Z3 w- t+ s2 D) v9 c$ L* J6 E) p# B$ ~$ H
        private static void getSubComponent(NXOpen.Assemblies.Component ParentComponent, TreeNode parentNode)$ M9 o9 k6 q8 N0 D, A
        {
4 P5 P) O8 `% F9 @2 D5 i- U  k' K0 N            NXOpen.Assemblies.Component[] sub_component = ParentComponent.GetChildren();
. `1 u- i9 d% h( B            foreach (NXOpen.Assemblies.Component comp in sub_component)& r' e( f1 Y3 |; @& `. w, f
            {
: ~/ G' n' v5 u  W' g) K                TreeNode subNode = new TreeNode();3 i2 o7 O  H- g# ]3 m* x- ?" ^
                subNode.Name = comp.JournalIdentifier;
* r) a, d# V, d1 I                subNode.Text = comp.DisplayName;
5 }( }# }8 t% M4 i5 G, q                parentNode.Nodes.Add(subNode);% H' V" b2 V/ H3 ]+ |2 W
                if (comp.GetChildren().Length > 0)* i% J9 K3 x8 S  L/ B
                {
" N) Z$ ~4 p5 v) B                    getSubComponent(comp, subNode);% J2 `) X# C5 j5 n
                }
8 M  Q7 H8 x, q            }
0 i9 L: n" B2 z4 C3 D9 y+ Q% D            ParentComponent.Blank();' K2 i  |9 C5 D! f& S
            int sub_num = sub_component.Length;; w. G  a2 a% U7 T4 v8 O0 q9 R
        }: H! e3 |4 U, L0 r! `) q1 ~
}: Z' ]5 \4 @) E% E/ R8 C/ o
回复

使用道具 举报

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

使用道具 举报

 楼主| 发表于 2014-9-26 09:24 | 显示全部楼层
danyfer 发表于 2014-9-26 06:05( w1 v0 Q1 ^5 X9 o* M3 h  j
支持一下…………
* _3 p! |! ^" P! G, f/ X- q, g
谢谢,能帮着编一个这样的程序吗?
3 L7 h2 v$ c! h$ S$ m5 P' q  ?
回复

使用道具 举报

 楼主| 发表于 2014-10-3 19:42 | 显示全部楼层
danyfer 发表于 2014-9-29 13:18) U0 G8 d% m4 A5 `, f7 e
private static Session theSession;
! K0 g& k+ \8 T1 _: M0 g( [3 _& E2 |        private static UI theUI;
$ j5 t# R5 P4 t; K+ @3 E4 w        private static UFSessi ...
  J! V8 t0 f8 l+ X
太感谢了,我试试
" D0 R9 _( n/ R* ?9 ]$ r9 r0 Z$ a0 h9 R
回复

使用道具 举报

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

使用道具 举报

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-2-2 06:47 , Processed in 0.050984 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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