2012년 12월 26일 수요일

html tag


google go!

:a태그는 링크를 걸수있다.

:href속성은 주소를

:target속성의 값을 _blank로주면 새창으로 열수있다.

바로가기는 어디?
:abbr태그는 글자에 마우스를 가져다데면 설명을 볼수있는 기능

2012년 9월 18일 화요일

select의 요소


use tempdb

--태이블생성
create table dbo.customers
(
Num int identity(1,1) primary key,
Name varchar(25) not null,
Age tinyint null,
Address varchar(100)
)
go

--샘플 데이터 입력
insert customers values('태연',21,'서울')
insert customers values('설리',19,'서울')
insert customers values('수지',19,'인천')
insert customers values('나은',18,'대전')
insert customers values('리지',20,'서울')
insert customers values('지효',31,'부산')
insert customers values('보라',31,'부산')
insert customers values('보미',20,'광주')
go


update customers
set Address= '부산'
where  name='태연'



select * from customers
go
--1.중복제거(distinct)
select distinct address from customers
--2.집계함수 그룹화: 같은 지역 고객의 나이의 평균
select address, AVG(age) from customers
group by address

--3.조건이 있는 집계함수 그룹화: 같은지역 아이돌중 나이가 20이상인
-- 아이돌나이의 평균
select address,AVG(age) from customers
where age >= 20
group by address

select address,AVG(age) from customers
where age >= 20
group by all address

--4.having:집계함수에 대한 조건처리
--같은 지역 아이돌의 나이의 평균이 20 이상인 데이터만 출력

select address,AVG(age) from customers
group by address
having AVG(age) >= 30

--5.rollup:소계: 지역별 나이들 출력후 나의 소계(중간 합계)
select address,AVG(age) from customers
group by address with rollup

--6.cube
select address,AVG(age) from customers
group by address with cube

--7.grouping()함수
--
select address,AVG(age),GROUPING(address) as 그룹화여부
from customers
group by address with cube

--8.compute :출력 결과에 대한 집계
select address, age
from customers
compute sum(age),avg(age)

--9.compute by :출력 결과에 대한 집계에 대한 정렬
select address, age
from customers
order by address
compute sum(age),avg(age) by address

--10.case:문장대체
select name, age,
address = case address when '서울' then 'seoul'
when '부산' then 'busan'
else '다른지역'
end
from customers

2012년 9월 3일 월요일

외부스타일시트를 쓸때


<link
rel="stylesheet"
type="text/css"
href="./common/global.css"
>
외부스타일시트를 쓸때

CSS 속성

이미지
float :이미지 옆에 문자를 배치하도록한다.(left,right,none)
clear:이미지 옆에 문자를 오지 못하게(left,right,both)




color :글자색
font-size :크기
font-family :글꼴
font-weight :<h>
font-style :<i>
line-height :줄간격
text-decoration : 밑줄,취소선,윗줄
text-align :수평정렬
vertical-align :수직정렬
text-transform :첫자 대문자,모두 대문자,모두 소문자.
text-indent :들여쓰기
width :가로(모든객체)
heigth :세로(모든객체)
padding :안쪽여백
margin :바깥쪽여백
letter-spacing :문자간격
word-spacing :단어간격
border :테두리(color,width,style)
background-color :배경색
background-image:url() :배경이미지
background-repeat :배경 이미지의 반복여부
background-position :배경 이미지의 위치
background-attachment :배경이미지 고정여부
cursor :커서모양
a:link :기본링크
a:visited :방문한 링크
a:active :활성된링크
a:hover :마우스를 위에 올려놓을때
scrollbar :스크롤바모양
list-style-type :리스트모양
float :이미지와 택스트간의 배치설정
clear :이미지와 택스트간의 배치성정 해제

2012년 8월 31일 금요일

선택정렬 알고리즘

<script language="javascript" type="text/javascript">

var sort = [33, 22, 11, 55, 44];
var temp = 0;

for (var i = 0; i < sort.lngth; i++)
{
for(var j = i + 1; j < sort.length; j++)
{
if(sort[i] > sort[j])
{
temp = sort[i];
sort[i] = sort[j];
sort[j] = temp;
}
}
}

for(var i = 0; i < sort.length; i++)
{
document.write(sort[i] + " ");
}
document.write("<br />");

</script>

내장함수

// JavaScript Document
<script type="text/javascript">

 //eval() :연산식을 계산해준다.
 var str="3 + 5";
 document.write(str);
 document.write("<br />");
 document.write(eval(str));
 document.write("<br />");


 //parsInt() :실수를 정수로
 var num = 12.34;
 document.write(num);
 document.write(parseInt(num));

 //parsfloat() :수 -> 실수
 var su = "12.34";
 document.writeln("<br />");
 document.writeln(typeof(su),"<br />");
 document.writeln(typeof(parseFloat(su)),"<br />");

 //typeof() 연산자 :현제값의 유형을 반환시켜주는 연산자.
 var nan ="안녕";
 document.write(parseFloat(nan),"<br />");

</script>

2012년 8월 26일 일요일

corsor

일반텍스트
기본값
자동
도움말
+표기
손모양
모래시계
텍스트
움직임
포인터
방향관련

2012년 8월 20일 월요일

for문


<script language="javascript" type="text/javascript">
var sum = 0;
for(var i = 1; i <= 100; i++ )
{
if(i % 3 == 0 || i % 4 == 0)
{
sum += i;
}
}
document.write(sum);
</script>


<html>
<body>
<script language="javascript" type="text/javascript">
var a = 1;
var b = 10;

for(var i = 0; i < 10; i++)
{
document.write(a++ +"," + b-- + "<br />");
}
</script>
</body>
</html>

2012년 6월 25일 월요일

shop


2D데이터를 기반으로한 shop drawing 캐드 애플리캐이션을 만든다.
롤자재의 규격은 미리 입력해놓은 것을 선택할수 있다.
자재의 규격을 추가할수있다.
자재의 규격을 잘못입력했을경우 수정할수있다.
프로젝트별로 작업이 관리된다.
프로젝트별로 디랙토리를 개별로 가진다.
프로잭트의 공통정보를 관리한다.
스탠다드의 개념인 커넥션 유형을 미리 정의한다.
디태일작업시 스탠다드를 이용하여 커넥션을 그리게한다.
디태일작성시 디태일 리스트를 만든다.


관리되는 시트를 만들수 있을까?
요즘 BIM툴과 같이 그림과 데이터를 서로 연관시켜서 서로 수정을 적용시킬수 있을까?
2d의 장점인 간편함과 유연성을 해칠까?
디태일을 하다보면 끈임없이 바뀌는 정보들을 관리해야됨으 느끼게된다.
하지만 한개의 작업만 집중할수있는 여건이 되지 못한다.
여러개의 작업이 동시에 이루어지게되며 각각의 작업은 서로 다른 데이터를 가지게되는데
이것이 매우 해깔리게 되어 실수를 유발하게한다.
이러한 실수를 방지할수잇게 작업의 정보를 데이터화 할수 있다면 좋겠다.
설정과 데이터들은 파일로 기록된다.


*디테일을 위한 작업
위치와 방향을 확인한다.
상부와 하부의 커넥션을 확인한다.
연결부위를 확인한다.
길이를 확인한다.
들어오는부제의 단차와 규격을확인한다.

col의 물건길이는
플로어포인트 와 커넥션에의해 늘어나고 줄어드는 길이값을 적용
col의경우 상부의 접합
하부의 접합
들어오는 빔과 브래스 거스와 퍼린 등등 적용해야할 대상이 너무나도 많다.

매인자재를 생성하는것과
서브자재의 접합을 생성하는 파트를 나눌수 밖에 없을듯 하다.


자재간의 접합
구조상의 명시된값으로 프로잭트별로 관리된다.
자재별로 다르고 같은 규격의 자재더라도 쓰임에따라 다른 값을 가진다.
강접합과 핀접합은 구별되어야하며 모양은 비슷하지만 전혀 다른 특성을 가진다.

*Column
length :입면상의 포인트 상부와 하부의 연결접합 방법에 따른 치수 차.

규격 : 디태일되는 부재의 규격싸이즈 부재를 선택시 마크를 선택하면 그에
          매치되는 부재사이즈가 선택된다.

커넥션 : 상부와하부의 커넥션(메인),
             플로어를 지탱하는 부재와의 커넥션(서브),
             기둥과 기둥을 엮는 가설재(서브),
             수직과 수평브래스(서브),
             마감과 관련되 거스및 퍼린(서브).
*메인 커넥션외의 서브 커넥션의 경우 개별정의후 삽입하는 방식이 더 효율있을것같다.


*Beam 
빔은 포인트(평면상의 위치와 입면상의 위치)와 자체규격
상관관계에 있는 자재의 규격과 포인트에 의해서 결정된다.
빔역시 메인과 서브를 따로 해야하지 않을까?


length :p/p 구조 평면상의 값
           상관관계의 부재와의 차의값
           커넥션에의한 치수값

규격 : 메인 디테일되는 부재의 사이즈 정보
         상용화되는 롤자재는 사전에 정의 돼어있다.(R값등..)

커넥션 : 디태일되는 부재의 커넥션, 칼람 또는 빔(메인),
             부재에 와서 접합되는 부재를 받기위한 웨브방향 커넥션(서브),
             부재에 플랜지와 접합하는 커넥션(서브),

*표준 부재규격

상용화된 H-BEAM의 규격정보를 데이터로 사전정의 한다.
모든프로잭트에 적용된다.

*프로잭트 마크시스탬

표준부재규격에 등록된 규격정보와 프로잭트의 구조상의 마크를 매치해서 프로잭트 부재규격을 정의한다.
표준규격이외의 부재를 추가할수있다.

*커넥션 스탠다드

구조에따라 마크별로 일반적인 커넥션 정보를 지정해놓는다.
takla의 메크로와 같은식으로.
홀크기와 볼트크기,갯수,플래이트 사이즈등이 정의 된다.
각각의 커넥션에는 이름을 붙일수 있으며 언재든지 추가이름바꾸기,삭제를 할수있다.


*작업순서
프로잭트 마크시스탬을 작성한다.
커넥션 스탠다드를 작성한다.
col 메인부재 작성
색션 생성
col 소부재 작성
색션 생성
shop넘버 지정
bom작성
드로잉 리스트로 넘버 넘기기


*구현
H-BEAM class
//h-beam 공장에서 용도에 맞게 자르고 홀을 뚫고,가세트를 붙이는등의 가공을한후
//현장에서 조립한다.
-double[] 규격
-bool 수직재
-string 마크
+double 길이()

마크시스템 class
//마크를 입력받아

2012년 6월 23일 토요일

로그인폼


        private void loginbutton_Click(object sender, EventArgs e)
        {
            if (checkData() == true)
            {
                this.label1.Text = "로그인 성공";
            }
        }

        private bool checkData()
        {
            if (this.idtextBox.Text == "")
            {
                MessageBox.Show("로그인 아이디를 입력하세요", "알림", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.idtextBox.Focus();
                return false;
            }
            else if (this.passtextBox.Text == "")
            {
                MessageBox.Show("로그인 비밀번호를 입력해주세요", "알림", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.passtextBox.Focus();
                return false;
            }
            else
            {
                if (this.idtextBox.Text == "test")
                {
                    if (this.passtextBox.Text == "12345")
                    {
                        return true;
                    }
                    else
                    {
                        this.label1.Text = "일치하는 비밀번호가 없습니다.";
                        this.passtextBox.Focus();
                        return false;
                    }
                }
                else
                {
                    this.label1.Text = "일치한는 아이디가 없습니다.";
                    this.idtextBox.Focus();
                    return false;
                }
            }
        }

       

        private void passtextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (checkData() == true)
                {
                    this.label1.Text = "로그인성공";
                }
            }
        }

        private void closebutton_Click(object sender, EventArgs e)
        {
            this.Close();
        }
     

     
    }

2012년 6월 21일 목요일

기본문법(타입)


값 타입


스택에할당

-구조체

struct 이름
{
맴버 선언문
}

맴버선언문에는 필드와 메소드 생성자등을 선언 할수있다..
필드는 한정자를 따로 정하지 않으면 private이다.

구조체는 변수 선언후 바로 변수를 쓸수있다(클래스는 인스턴스 생성후 사용 가능)

구조체타입 구조체 변수 = new 구조체타입();
new는 생성자를 쓰기위함다.(인스턴스는 만들어지지않고 힙에 할당 돼지 않는다.)



참조타입

힙에 할당
사용이 끝나면 가비지컬렉터에 의해 메모리가 관리된다.


-배열


타입[] 변수명;

배열은 참조형이므로 변수 자체가 실제 데이터를 저장하지 않는다.(변수는 null값을 가진다.)
new 연산자에 의해 힙에 데이터 저장을 위한 별도의 공간이 할당되고 배열
변수는 이 위치만을 가진다.



타입[] 변수명 = new 타입[];

int[] arr = new int[5] {1, 2, 3, 4, 5};

arr은 정수형 배열이며 5개의 공간을 할당 받으며 각각의 공간이 {}안의 값들로 초기화 된다.
초기값이 있을시에 []안의 배열의 길이를 표기할 필요가 없다.
컴파일러가 요소의 수를 세어 메모리 크기를 할당하기 때문에 초기값이 있을시엔
배열의 크기를 표기 않는것이 좋다.

int[] arr = {1, 2, 3, 4, 5};

new int[] 마저 생략되었는데 이유는
초기값이 있으므로 메모리를 할당할것으로 인식하는 똑똑한 컴파일러를 가지고 있기 때문

배열의 초기값은 메모리를 할당받은후에는 할수 없다.
즉 다음은 컴파일 되지 않는다.

int[] arr = new int[5]; //초기화 하지 않으면 길이를지정 해야하는듯..(확인않함)
arr = {1, 2, 3, 4, 5};



2012년 6월 19일 화요일

list


    class Program
    {
        static void Main(string[] args)
        {
            List<test> testList = new List<test>();
            testList.Add(new test() { name = "a", num = 100 });
            testList.Add(new test() { name = "b", num = 200 });

            foreach (test a in testList)
            {
                Console.WriteLine("name ={0},\n num = {1}", a.name, a.num);
            }
           
        }
    }

    public class test
    {
        public string name;
        public int num;
    }
}

list에 객체를 담아본다.

2012년 6월 15일 금요일

수학함수

using System;




class MathTest1
{
static void Main(string[] args)
{
// 절대값


// 절대값이란, 수직선상에서 0으로부터의 거리입니다. 스칼라양이죠.
// 참고로 스칼라란 크기만 있는 값이고, 벡터는 크기와 방향이 있는 값입니다.
// 따라서, 절대값을 풀면 항상 양의 값만 나옵니다.




double d1 = -1.23;
double d2 = Math.Abs(d1);
Console.WriteLine("Math.Abs {0} => {1}", d1, d2); // Math.Abs -1.23 => 1.23




// 올림
d1 = 1.23;
d2 = Math.Ceiling(d1);
Console.WriteLine("Math.Ceiling {0} => {1}", d1, d2); // Math.Ceiling 1.23 => 2


d1 = -1.23;
d2 = Math.Ceiling(d1);
Console.WriteLine("Math.Ceiling {0} => {1}", d1, d2); // Math.Ceiling -1.23 => -1




// 내림
d1 = 1.23;
d2 = Math.Floor(d1);
Console.WriteLine("Math.Floor {0} => {1}", d1, d2); // Math.Floor 1.23 => 1


d1 = -1.23;
d2 = Math.Floor(d1);
Console.WriteLine("Math.Floor {0} => {1}", d1, d2); // Math.Floor -1.23 => -2




// 반올림
d1 = 1.23;
d2 = Math.Round(d1);
Console.WriteLine("Math.Floor {0} => {1}", d1, d2); // Math.Round 1.23 => 1


d1 = -1.23;
d2 = Math.Round(d1);
Console.WriteLine("Math.Floor {0} => {1}", d1, d2); // Math.Round -1.23 => -1




// 최대값
d1 = 1;
d2 = 2;
Console.WriteLine("Math.Max {0} , {1} Max {2}", d1, d2, Math.Max(d1, d2)); // Math.Max 1 , 2 Max 2




// 최소값
d1 = 1;
d2 = 2;
Console.WriteLine("Math.Min {0} , {1} Min {2}", d1, d2, Math.Min(d1, d2)); // Math.Min 1 , 2 Min 1




// power
d1 = 10;
d2 = Math.Pow(d1, 2);
Console.WriteLine("Math.Pow {0} => {1}", d1, d2); // Math.Pow 10 => 100




// 계산테스트
double a = 16666.67;
double b = 3333.33;
double c = a - b;
Console.WriteLine("{0}", c); // 결과 : 13333.34




// 표시는 13333.34 로 되지만 실제로 13333.34 값과 비교해 보면 "다르다" 라고 나온다.
if (c == 13333.34)
{
Console.WriteLine("같다");
}
else
{
Console.WriteLine("다르다"); // "다르다"
}




double d = 13333.339999999998;
Console.WriteLine("{0}", d); // 결과 : 13333.34




if (c == d)
{
Console.WriteLine("같다"); // "같다"
}
else
{
Console.WriteLine("다르다");
}




d = 13333.33999999999;
Console.WriteLine("{0}", d); // 결과 : 13333.34




if (c == d)
{
Console.WriteLine("같다");
}
else
{
Console.WriteLine("다르다"); // "다르다"
}




d = 13333.3399999999;
Console.WriteLine("{0}", d); // 결과 : 13333.3399999999


}
}
[출처] C# 수학함수|작성자 빨간토끼

2012년 6월 8일 금요일

변수

VTENABL zoom속도

2012년 6월 5일 화요일

attext 탬플릿

BL:NAME 블럭이름
필드이름 C010000  ;C는 문자 000 은정수부분 위의000은 소수부분
필드이름 N010000  ;N은 숫자  
반드시 대문자.
스크립시 ATTDIA변수설정.

2012년 6월 2일 토요일

크리스탈리포트 다운로드 링크
http://www.businessobjects.com/jump/xi/crvs2010/us2_default.asp

2012년 5월 29일 화요일

디맨션 코드

10 = 치수선 위치
13 = 치수선 지시선 시작(지적위치)
14 = 치수선 지시선 끝
1 = 문자재지정
42 = 측정문자

2012년 5월 25일 금요일

공동수도요금 계산및납부안내문 출력하기

공부하면서 만들려고함



*개요
매월 수도요금을 세대별 사용량에따라서 요금을 나누어서 징수하기위한
프로그램을 만들기로 한다.

*필요요소
월사용량을표기
전체 사용 요금을 표기한다.(전체사용요금은 공동전기등의 추가합산요금이된다.)
각세대를 표기하고 각각의사용량에 따른 이달납부 금액을 표기한다.
(미납금존재시 추가표기)

*디자인
전체사용량과 요금을 입력하면 전체사용량을 요금에 나누어서
단위요금을 계산해서저장
세대별 사용량을 입력하면 전달사용량에서 이달사용량을 뺀값을
단위요금을 곱해주어 이달 요금을 출력한다.


*입력란(전체)
-월사용량(int)
-월사용금액(int)
+단위 사용량 요금계산( )
+세부내역 추가( )
-세부내역(string)

*입력란(세대별)
-이전달 사용량(int)
-월사용량(int)
+월사용 요금계산출력( int 이전사용량, int 이달사용량)

2012년 5월 2일 수요일

application 갱신하기


Aplication.DoEvents();

2012년 5월 1일 화요일

지연하기

System.Threading.Thread.Sleep(3);


2012년 4월 25일 수요일

조건문(switch)




namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string caseValue;

            Console.Write("입력 :");
            caseValue = Console.ReadLine();

            switch (caseValue)//정수,문자열,bool,char,enum등이 될수있다.
            {
                case "aa":
                    Console.WriteLine("case1문장");
                    break;

                case "bb":
                    Console.WriteLine("case2문장");
                    break;
                case "cc":
                    Console.WriteLine("case3문장");
                    break;
                default://위의 case의 값과 일치하지 않을경우 default실행
                    Console.WriteLine("나머지...");
                    break;

            }
        }
    }
}

2012년 4월 24일 화요일

델리게이트




001: using System;
002: //델리게이트 선언
003: delegate void dele1();
004: delegate int dele2(int a,int b);
005: class MainClass
006: {
007:    static void Main(string[] args)
008:    {
009:           //Math클래스 선언및 인스턴스화
010:           MathClass MathClass=new MathClass();
011:           //델리게이트 선언및 인스턴스화
012:           dele1 Sum1=new dele1(MathClass.Intro);
013:           dele2 Sum2=new dele2(MathClass.Sum);
014:           //델리게이트에 위임된 메서드 실행
015:           Sum1();
016:           Console.WriteLine("Result : {0}",Sum2(-10,90));
017:    }
018: }
019: class MathClass
020: {
021:    public void Intro()
022:    {
023:           Console.WriteLine("계산을 시작합니다.");
024:    }
025:    public int Sum(int a, int b)
026:    {
027:           return a+b;
028:    }
029: }




using System;
002: delegate void deleMath(int Value); //델리게이트 선언
003: class MainClass
004: {
005:    static void Main(string[] args)
006:    {
007:           //Math클래스 선언및 인스턴스화
008:           MathClass MathClass=new MathClass();
009:        
010:           //델리게이트 선언및 인스턴스화(덧셈)
011:           deleMath Math=new deleMath(MathClass.Plus);
012:
013:           //위임연산(뺄셈,곱셈추가)
014:           Math+=new deleMath(MathClass.Minus);
015:           Math+=new deleMath(MathClass.Multiply);
016:           //결과1
017:           MathClass.Number=10;
018:           Math(10);
019:           Console.WriteLine("Result:{0}",MathClass.Number);
020:
021:           //위임연산(뺄셈제거)
022:           Math-=new deleMath(MathClass.Minus);
023:           //결과2
024:           MathClass.Number=10;
025:           Math(10);
026:           Console.WriteLine("Result:{0}",MathClass.Number);
027:
028:           //위임연산(곱셈제거)
029:           Math-=new deleMath(MathClass.Multiply);
030:           //결과3
031:           MathClass.Number=10;
032:           Math(10);
033:           Console.WriteLine("Result:{0}",MathClass.Number);
034:
035:    }
036: }
037: class MathClass
038: {
039:    public int Number;
040:    public void Plus(int Value)//더하기
041:    {
042:           Number+=Value;
043:    }
044:    public void Minus(int Value)//빼기
045:    {
046:           Number-=Value;
047:    }
048:    public void Multiply(int Value)//곱하기
049:    {
050:           Number*=Value;
051:    }
052: }

출처
http://hoons.kr/Lecture/LectureMain.aspx?BoardIdx=61&kind=4&view=0

2012년 4월 23일 월요일

파일과 디렉토리




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            DriveInfo di = new DriveInfo(@"c:\");//드라이브
            Console.WriteLine(di.TotalFreeSpace);
            Console.WriteLine(di.VolumeLabel);
            DirectoryInfo dirInfo = di.RootDirectory;//
            Console.WriteLine(dirInfo.Attributes.ToString());

            FileInfo[] fileName = dirInfo.GetFiles("*.*");//드라이브의 모든 파일목록 불러오기

            foreach (FileInfo fi in fileName)//FileInfo 형의 참조 fi 를 선언함과동시에 fileName의 조각들로 초기화 한다.
            {
                Console.WriteLine("{0}: {1}: {2}", fi.Name, fi.LastAccessTime, fi.Length);
            }

            DirectoryInfo[] dirInfos = dirInfo.GetDirectories("*.*");//드라이브의 모든 디렉토리 목록

            foreach (DirectoryInfo d in dirInfos)
            {
                Console.WriteLine(d.Name);
            }

            string currentDirName = Directory.GetCurrentDirectory();

            Console.WriteLine(currentDirName);

            string[] files = Directory.GetFiles(currentDirName, "*.txt");

            foreach (string s in files)
            {
                FileInfo fi = null;
                try
                {
                    fi = new FileInfo(s);
                }
                catch (FileNotFoundException e)
                {
                    Console.WriteLine(e.Message);
                    continue;
                }
                Console.WriteLine("{0} : {1}", fi.Name, fi.Directory);
            }

            if (!System.IO.Directory.Exists(@"C:\Users\Public\TestFolder\"))
            {
                System.IO.Directory.CreateDirectory(@"C:\Users\Public\TestFolder\");
            }

            System.IO.Directory.SetCurrentDirectory(@"C:\Users\Public\TestFolder\");

            currentDirName = System.IO.Directory.GetCurrentDirectory();
            Console.WriteLine(currentDirName);

            // Keep the console window open in debug mode.
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();

        }
    }
}

StreamWriter //파일에 쓸수있는 닷넷 객체.
StreamReader//파일을 읽어오는 닷넷 객체.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = "123456789";
            string b;
            using (StreamWriter sw = new StreamWriter(@"D:\test\test.txt", true))
            {
                sw.WriteLine(a);
            }
            //using 을 쓰면 파일을 직접닫지않아도됀다.
            // { }않의것을 처리후 자동으로 닫는다.
            using(StreamReader sr = new StreamReader(@"D:\test\test.txt"))

            {
             
                while ((b = b = sr.ReadLine()) != null)
                {
                    Console.WriteLine(b);
                }
               
            }

        }
    }
}

2012년 4월 10일 화요일

입력함수







getpoint <pt> [prompt]
      이 함수는 하나의 점을 입력하도록 대기한다. 인수인 점 Pt는 현재의 UCS내의 2D 또는 3D 좌표이다. 출력좌표는 3D 점이다.
       (setq pt1 (getpoint) )
       (setq pt1 (getpoint "Pick a point : "))

인수 pt가 있으떤 고무밴드 라인을 표시한다.
    (setq pt2 (getpoint pt1 "Pick a point : "))
    (setq pt2 (getpoint'(3.0 5.5) "Pick a point : "))

Program

  MGETPT.LSP

  프로그램 기능
이 프로그램은 화면에 여러 개의 점을 적으며 모든 점에 대한 3D 좌표 list를 출력 시킨다.

  프로그램 LIST
      (defun c:MGETPT (/ point pl )
         ( whi le
                (setq point (getpoint "\n Pick point" ) )
                (setq pl (append pl (list point) ))
         )
        (princ "\n-- List of points --" )
        (terpri)
        (princ pl )
        ( princ )
     )
     ,,:
getreal [prompt]
      이 함수는 실수를 입력하도록 대기하고 그 실수를 출력한다
   (setq real (getreal ) )
   (setq real (getreal "Enter length of line : ") )

getstring [cr] [prompt]
      이 함수는 문자열을 입력하도록 대기하고 그 문자열을 출력한다.
   입력할 최대문자수는 132자이다. 이것을 초과하면 132자에서 문자열이 끊긴다. 문자열에 '\'를 입력하면 두 개의 "\\"로 변환되는데 이것이 출력되어 다른 함수가 사용할 file명 Path를 포함할 수도 있으므로 그렇게 된다.

    cr이 주어지고 그 값이 nil이면 문자열에 공백을 넣을 수 있다. (그래서 반드시 앤터로 끝나야 한다. ) 그렇지 않으면 입력 문자열은 스페이스바나 엔터에 의해 종료된다. 또한, 사용자가 입력할 키워드를 미리 정해 둘 경우에는 getkword함수를 써야 한다

      (setq str ("getstring "Type string : ")
      입력: AutoLISP --> "AutoLISP".

      (setq str (getstring T "Type string ")
      입력: AutoLISP( spacebar)PROGRAM --> "AutoLISP PROGRAM"

          (위에서 T가 없으면 (spacebar)부분에서 입력이 종료되어 버린다. )

      (setq str (getstring "Enter file name to load : ")
      입력 :\ACAD12\PRJT05\TPIPE --> "\\ACAD12\\PRJT05\\TPIPE"


getdist [pt] [Prompt]
      이 함수는 길이를 입력하도록 대기하고 입력한 길이 또는 두 점간의 길이를 계산하여 출력한다. 점 Pt가 주어지면 화면에 고무밴드 라인이 나타나며, pt는 현재의 UCS내의 2D 또는 3D 점이다.
      init함수에 64비트를 설정하면 z좌표값은 무시되고 20거리를 출력할 수 있다.

     (setq dist (getdist) ) "
     (setq dist (getdist pt1 ) )"
     (setq dist (getdist "Pick or Enter distance : "))"
     (setq dist (getdist pt1 "Pick endpoint : ") )"

getcorner <pt> [prompt]
      getpoint처럼 한 점을 출력하는 것은 같으나 다른 점은 다음과 같다.
        1. 인수 Pt가 있어야 한다.
       2. Pt점에서부터 사각형 틀이 표시된다.

getorient [pt] [prompt]
      이 함수는 getangle파 같은 기능을 한다.
다만 다음 사항이 다르다.
    1. 출력되는 각도가 시스템변수 ANGBASE(0도 지점)와 ANGDIR(각도증가 방향)의 영향을 받지 않는다.
    2. ANGBASE와 ANGDIR의 값이 어떻든지 getorient는 항상 radian 0도 지점을 오른쪽(동쪽,3시방향)에 두고 각도 증가는 시계반대 방향으로 각도를 잰다. (AutoCAD 사용자는 UNITS명령으로 일반적으로 이와 같이 설정해 놓고 있다. ) 입력 각도와 getorient로 출력되는 각도는 서로 다르다
    3. getorient에 의해 각도를 입력할 때는 ANGBASE와 ANGDIR의 현재 값을 기준으로 한다.
     4, 그러나 일단 입력된 각도는 ANGBASE와 ANGDIR의 현재 값을 무시하고 위의 2번항과 같이 잰다

그래서 사용자가 UNITS명령이나 시스템변수 ANGBASE와 ANGDIR을 사용해서 0도지점과 각도 증가 방향을 바꾸면 약간의 변환 과정을 거쳐야 한다.
절대각도인 entity가 진행할 방향각을 구하기 위해서는 getangle을 사용하는 반면 상대각도인 rotate각도를 입력할 때는 getorient를 사용해야 한다.

getkword [prompt]
      사용자가 키워드를 입력하도록 대기하며, 키워드 리스트는 getkword를 호출하기 전에 initget함수를 사용하여 설정해 놓아야 한다. 이 함수는 사용자가 입력한 문자열에 부합되는 키워드를 출력한다. 키워드에 없는 문자열은 무시되며 null입력이 허용되면 null은 nil로 출력된다. 키워드가 전혀 설정되어 있지 않으면 nil이 출력된다.
       ( initget 1 "YES NO")
       (setq ans (getkword "Answer (YES/NO) : ") )

initget [bits] [string]
      이 함수는 다른 함수가 사용할 여러 가지의 option을 사전에 설정해 주고 항상 nil을 출력한다. initget을 사용하는 함수는 다음과 같다.
        getxxx (단, getstring, getenv, getvar는 제외)
        entsel nentsel nentselp
  인수 bits는 정수로서 다음과 같다.

     INITGET함수 BIT코드표
-------------------------------------------------------------------------------
   bits            의미
-------------------------------------------------------------------------------
1               null입력을 허용치 않는다.
2               0인 값을 허용치 않는다.
4               음수 값을 허용치 않는다.
8               LIMCHECK가 ON상태에서도 설계 한계점을 검사하지 앉는다.
16             (현재 사용하지 않는다. )
32             고무밴드라인이나 박스를 dashed line 으로 표시 한다.
64             getdist에 한해 3D의 Z좌표를 무시한다.
128             임의 키보드입력을 허용한다.
 -------------------------------------------------------------------------------

getint [prompt]

   이 함수는 사용자의 정수 입력을 대기하고 그 정수를 출력한다.
정수범위는 -32,768 - 32,768이다.

Program

AUTONUM.LSP

프로그램 기능
   지정한 길이 내에 지정한 숫자들을 순서대로 배열한다

프로그램 LIST
    (defun c:AUTONUM (/ SNO ENO PT DIST ANG HGT NO STR)
             ( setq SNO (getint "\n>>> Starting number: " ) )
             (setq ENO (getint "\n>>> Ending number: " ) )
             ( setq PT (getpoint "\n>>> from point; " ) )
             ( setq DIST '(getdist PT "\n>>> Distance between numbers: "
             (setq ANG (getangle PT "\n>>> Angle for array/<0>: " ) )

           (if (: ANG nil) (setq ANG 0))
           (setq HGT (getdist PT "\n>>> Text height, " ) )
           (if (> SNO ENO)
                 (setq NO -1 )
                 (setq NO 1)

           )::if
           (repeat (+ 1 (abs (- SNO ENO)))
                 (setq STR ( itoa SNO) )
                 (command "text" "s" "standard" PT HGT ANG STR)
                 (setq SNO (+ SNO NO))
                 (setq PT (polar PT ANG DIST) )
           ) : : repeat
           ( princ )

프로그램 설명
    ( setq SNO (getint "\n>>> Starting number: " ) )
    (setq ENO (getint "\n>>> Ending number " ) )
계산을 위한 숫자가 아니므로 문자열로 입력받는다.

     (setq PT (getpoint "\n>>> from point: ") )
 점을 입력하면 그 점의 3차원 좌표(x,y,z)가 PT에 저장된다.
     ( setq DIST (getdist PT "\n>>> Distance between numbers: " ) )
getdist에 인수 PT를 붙이면 고무밴드 drag line이 나타난다.
     ( setq ANG (getangle PT "\n>>> Angle for array numbers<0>: " ) )
getangle에도 인수 PT를 붙이면 고무밴드 drag line이 나타난다.
     (if (: ANG nil) (setq ANG 0))
각도를 입력하지 않으면 즉 ENTER를 누르면 0도로 한다.
     (setq HGT (getdist PT "\n>>> Text height, " ) )
text의 높이 입력은 getdist를 사용한다.
     (if (> SNO ENO)
if조건 문으로서 시작 숫자가 종료 숫자보다 클 때,
( i f-then-el so )
           (setq NO -1 )
           (setq NO 1)
변수 NO를 -1로 설정하고 (then)
그렇지 않으면 변수 NO를 -1로 설정한다. (else)
     (repeat (+ 1 (abs (- SNO ENO)))
repeat반복문이 다.
반복 횟수는 두 개의 숫자를 뺀 숫자를 절대값으로 만든 후에 1을 더한 수가 된다.
           (setq STR ( itoa SNO) )
정수 SNO를 문자열로 변환시킨다.

           (command "text" "s" "standard" PT HGT ANG STR)
입력된 data와 계산한 결과로 text명령을 실행한다.
          (setq SNO (. SNO NO))
매 번 숫자가 증가되도록 한다.

           (setq PT (polar PT ANG DIST) )
PT를 재 정의하여 숫자의 위치가 매번 규칙적으로 변경되도록 한다.


Program
ANGDIS.LSP

프로그램 기능
   지정한 두 점간의 각도와 거리를 화면에 출력한다.

프로그램 LIST

(defun c:ANGDIS ( / pt1 pt2)
    (setq pt1 (getpoint "\nFirst point: " ) )
    (setq pt2 (getpoint "\nSecond point: ") )
    (setq ang (angle pt1 pt2) )
    (princ "\nAngle(degree) " )
    (princ (* (/ ang pi) 180.0))
    (setq dist (distance pt1 pt2) )
    (princ " Distance :")
    (princ dist )
    ( princ )
)


프로그램 설 명
         (setq pt1 (getpoint "\nFirst point: " ) )
         (setq pt2 (getpoint "\nSecond point: " ) )
점좌표값을 pt1 , pt2에 저장한다.

         (setq ang (angle pt1 pt2) )
pt1에서 pt2로 향한 radian각도를 재어 ang에 저장한다.

          (princ "Angle(degree) : " )
command line에 Angle이 표시된다.

         (princ (* (/ ang pi) 180.0))
radian각도를 degree단위로 변환시켜 화면에 나타낸다.

         (setq dist (distance pt1 pt2) )
두 점간의 거리를 재어 dist에 저장한다.

         (princ " Distance :")
         (princ dist)
거 리 를 표시 한다.



Program

MCIRCLE.LSP

프로그램 의 기능
   이 프로그램은 지정한 지름을 가진 원을 지정한 수량만큼 지정된 위치에 그린다

프로그램 리스트
    (defun C:MCIRCLE (/ NO DIA MUL CEN)
       (setq NO (getint "\n Number of circle: " ) )
       (setq DIA (getdist "\n Diameter of circle (pick or type) : "))
       (if (: DIA nil)
             (setq MUL MUL)
             (setq MUL DIA)
       )::if
       ( repeat NO
           (princ "\n Diameter of circle (pick or typel'")
           (princ MUL)
           (setq CEN (getpoint "\n Center-point of circle (pick or type) : "))
           (command ^Circle" CEN "d" MUL)
       ) : : repeat
    ): :defun
    ::;

프로그램 설 명
        (setq NO (getint "\n Number of circle: " ) )
그리고자 하는 원의 개수(NO)를 정수로 입력받는다. (get integer)
       (setq DIA (getdist ")sn Diameter of circle (pick or type) : "))
원의 지름을 입력 대기한다. (get distance)
       (if (: DIA nil)
             ( setq MUL MUL)

             (setq MUL DIA)
원을 두 개째 그릴 때는 이미 입력한 DIA를 사용한다.
       ( repeat NO
다음 과정을 개수 NO만큼 반복 수행(repeat)한다.
            (princ "\n Diameter of circle (pick or type) : ")
            (princ MUL)
지름의 현재 값을 출력한다. 프로그램이 가지고 있는 MUL을 내놓는다.
이 MVL을 NO횟수만큼 내놓아서 연속해서 원을 그릴 수 있도록 해준다.
    (setq CEN (getpoint "\n Center-point of circle (pick or type) :

                                                                                    "))
원의 중심점을 입력 대기한다.

            (command ^Circle" CEN "d" MUL)


AUTOCAD의 circle명령으로 NO횟수만큼 원을 그릴 수 있다.


Program

PBOX.LSP

프로그램의 기능
   이 프로그램은 pline으로 box를 그린다.

프로그램 리스트
    (defun DTR (a)
          (* pi (/ a 180.0))
    )
    l inriiipnnii#ifiiiiuuiiiinHiilitnpfiriiHniu

    (defun C: PBOX (/ pt1 p xlen ylen)
       (setq pt1 (getpoint "\n Start point of Pline box: ") )
       (setq xlen (getdist pt1 "\n x-length of Pbox (Pick or Type) : '
       (setq ylen (getdist pt1 "\n y-length of Pbox (Pick or Type) : '
       (setq pt2 (polar pt1 0 xlen) )
       (setq ptS (polar pt2 (dtr 90) ylen) )
       (setq pt4 (polar ptS (dtr 180) xlen)
      (command "pl me" pt1 pt2 pt3 pt4 ^Close")
      (command "rotate" "1· ". pt1) : 1=last
      ( terpri )
      ( princ "\n‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥ )
      (princ "\n x-length of Pbox : ")
      (princ xlen)
      (princ "\n y-length of Pbox : ")
      (princ ylen)
      (princ )
   )
   :::

프로그램 설명
    (defun DTR (a)
           (* pi (/ a 180,0))
    )

degree각도를 radlian으로 변환시키는 프로그램이다.
        (setq pt1 (getpoint "\n Start point of Pline box: ") )
점을 pick하면 pt1에는 좌표값이 저장된다.
        (setq xlen (getdist pt1 "\n x-length of Pbox (Pick or Type): ") )
        (setq ylen (getdist pt1 "\n y-length of Pbox (Pick or Type): "))
getdist 다음에 좌표값을 가진 pt1을 두면 화면에 고무밴드 drag line이 나타난다.
         (setq pt2 (polar pt1 0 xlen))
         (setq ptS (polar pt2 (dtr 90) ylen) )
         (setq pt4 (polar pt3 (dtr 180) xlen)
Polar함수가 출발점 -> 각도방향 릇 거리에 있는 점좌표를 구하여 각 변수에 저장한다.

            (command "pl me" pt1 pt2 pt3 pt4 ^Close" )
각 점좌표를 따라 pline으로 box를 그린다.

             (command "rotate" "1· ". pt1) : 1=last
그린 box를 rotate할 수 있도록 한다.
            ( terpri )
            ( princ "\n‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥ )

            (princ "\n x-length of Pbox : ")
            (princ xlen)
            (princ "\n y-length of Pbox : ")
            (princ ylen)
입력한 길이 값을 화면에 나타낸다.

출처

http://amadis.selfip.com:8080/tc/amadis/category/autolisp-1?page=2

2012년 4월 5일 목요일

window form

사용자가 폼의 크기를 바꾸지못하게하는 폼속성
FormBorderStyle
MaximizeBox

2012년 4월 4일 수요일

표준 파일선택 대화상자

getfiled
이제서야 알았다니...

cad 도면상의 data를 추출

dataextraction 데이터 추출 마법사
속성블록과 같이사용하기 좋은거 같다.

layer제어


CAD)LAYWALK
CAD)LAYLCK
CAD)LAYULK
CAD)LAYLOCKFADECTL
CAD)LAYOFF
CAD)LAYON
CAD)LAYISO
CAD)LAYUNISO
CAD)LAYCUR(객체를 현제도면층으로)
CAD)LAYMRG(도면층 결합
CAD)LAYFRZ동결
CAD)LAYTHW


whgdtxt.shx
 한국어 글꼴

whgtxt.shx
 한국어 글꼴

whtgtxt.shx
 한국어 글꼴

whtmtxt.shx
 한국어 글꼴


2012년 4월 3일 화요일

line의 mid point


(defun c:lineMid()
  (setq selectSet(ssget))
  (setq entName(ssname selectSet 0))
  (setq ent(entget entName))

  (setq sp(cdr(assoc 10 ent)))
  (setq ep(cdr(assoc 11 ent)))
  (setq len(distance sp ep))
  (setq ang(angle sp ep))
  (setq mp(polar sp ang (/ len 2)))
 
mp
  )

선택한 라인의 중심점 찾는거

2012년 4월 2일 월요일

class 변수명 = new 생성자();

class 변수명 = new 생성자();
class 변수명;//class 복합데이타 타입의 변수가 생성이돼는데 참조형식이다.
new 생성자()//힙에 인스턴스(실체)를 만들고 변수명이 이를 가리키게 한다.

2012년 3월 31일 토요일

물량정리 LISP 만들기

배이직도면 상의 마크와 사이즈 정보 그리고 라인을이용한 물건의 길이를
txt파일로 저장한다.


베이직도면의 정보얻기
베이직도면에 명기돼는 멤버리스트를 txt파일로저장
ex)...("mark" "h400x300x8x13")

이렉션 드로잉상의 선택한 마크와 저장된 마크를 매치해서 사이즈를 파일로 쓴다.




;basic도면의 부재 싸이즈를 txt파일로
(defun c:atest (/ startPoint endPoint startPointArea
endPointArea stp2 edp2
v_len1 v_len2 v_len3 fd
file_m count pointTest areaList
xDistance xAngle sn en
)

  (setq var_osmode (getvar "osmode"))
  (setvar "osmode" 32)
  (setq pointTest nil)
  (setq areaList nil)
  (setq count 1)


  (prompt "\n한줄의 영역을 지정해주세요.")
  (setq startPoint (getpoint "\n시작점"))
  (setq endPoint (getcorner startPoint "\n두번째점"))
  (setq xDistance (distance startPoint endPoint))
  (setq xAngle (angle startPoint endPoint))



  (prompt "\n문자열이 포함된 영역을 지정해주세요")

  (while (= pointTest nil)
(setq startPointArea (getpoint "\n시작점"))

(if (/= startPointArea nil)
 (progn
(setq endPointArea (getcorner startPointArea "\n두번째점"))
(setq areaList
  (append
areaList
(append (list startPointArea) (list endPointArea))
  )
)
(setq count (+ count 1))
 )
 (setq pointTest 1)
)
  )

  (setq file_m (file_name2))

  (if (= file_m nil)
(setq file_m file_i)
(setq file_i file_m)
  )



  (setq v_len1 (abs (- (cadr startPoint) (cadr endPoint))))



  (setq sn 0)
  (setq en 1)

  (while (/= count 0)

(setq startPointArea (nth sn areaList))
(setq endPointArea (nth en areaList))
(setq v_len2 (abs (- (cadr startPointArea) (cadr endPointArea))))
(setq v_len3 (atoi (rtos (/ v_len2 v_len1) 2 0)))



(setvar "osmode" 0)

(repeat v_len3
 (setq a1 (ssget "c" startPoint endPoint '((0 . "text"))))
 (if (/= a1 nil)
(progn
 (setq fd (open file_m "a"))
 (princ (basic_mark a1) fd)
 (princ "\n" fd)
 (close fd)
)
 )
;;;선택영역에 텍스트가없으면 파일에 쓰지않음
 (setq stp2 (polar startPoint (+ pi (/ pi 2)) v_len1))
 (setq edp2 (polar endPoint (+ pi (/ pi 2)) v_len1))
 (setq startPoint
stp2
endPoint edp2
 )
)
(setq sn (+ sn 2))
(setq en (+ en 2))
(setq count (- count 1))
(if (/= count 1)
 (progn
(setq startPoint (nth sn areaList))
(setq endPoint (polar startPoint xAngle xDistance))
 )
 (setq count 0)
)
  )
  (setvar "osmode" var_osmode)
  (princ)

)


(defun basic_mark
  (a1 / num n a2 a3 a4 a5 b1 b2 b3 len_b1 len_b2 b6 b11 b22)
;;;a1~a5선택세트
;;;n 반복용
;;;len~ 길이를 이용한 정렬
;;;b~ 출력


; (setq a1(ssget "w" startPoint endPoint))
  (setq num (sslength a1))
  (setq n 0)

  (repeat 2

(setq a2 (ssname a1 n))
(setq a3 (entget a2))
(setq a4 (assoc 1 a3))
(setq a5 (cdr a4))

(if (= n 0)
 (setq b1 a5)
 (setq b2 a5)
)

(setq n (+ n 1))
  )

  (setq len_b1 (strlen b1))
  (setq len_b2 (strlen b2))
;(setq b6 nil)

  (if (> len_b1 len_b2)
(progn
 (setq b6 b1)
 (setq b1 b2)
 (setq b2 b6)
)
  )
  (setq b11 (strcat "\"" b1 "\""))
  (setq b22 (strcat "\"" b2 "\""))
  (setq b3 (list b11 b22))
)
;;;선택세트에서 문자열을 정리해서 리턴

(defun file_name2 (/ path_m name_m file_m) ;

;(setq path_m "c:/hello/")
  (setq path_m "C:/hmgTXT/")
  (setq name_m (getstring "\n파일이름을 입력하세요."))
  (if (= name_m "")
(setq file_m nil)
(setq file_m (strcat path_m name_m ".txt"))
  )

  file_m

)



;;;파일에서 읽어온문자를 도면의 글자와 대치해서 삽입

(defun c:etest (/ selectObjectSet
entname ent   num
n entTextvalueList
insertPoint textAngle   blockinsertPoint
entTextvalue markSize   file_m thelist
dcl_id selectFilevalue listboxValue listBoxtest
)

  (vl-load-com)
  (setq val_dimscale (getvar "dimscale"))
  (setq val_cmdho (getvar "cmdecho"))
  (setq val_attdia (getvar "attdia"))
  (setvar "attdia" 0)
  (setq val3 (/ val_dimscale 2))

  (setvar "cmdecho" 0)

  (setq thelist (vl-directory-files "C:/hmgTXT/" "*.txt" 1))

  (setq dcl_id (load_dialog "basicMarkFile.dcl"))


  (if (not (new_dialog "basicMarkFile" dcl_id))
(exit)
  )

  (start_list "selectFile")
  (mapcar 'add_list thelist)
  (end_list)

  (action_tile "cancel" "(setq listBoxtest 1) (done_dialog)")
  (action_tile
"accept"
"(setq listboxValue (atoi(get_tile \"selectFile\")))(done_dialog)"
  )


  (start_dialog)
  (unload_dialog dcl_id)
  (if (/= listBoxtest nil)
(exit)
(progn

  (setq selectFilevalue (nth listboxValue thelist))


  (setq file_m (file_name3 selectFilevalue))
  (if (= file_m nil)
(setq file_m file_i)
(setq file_i file_m)
  )

  (prompt "\n선택")

  (setq selectObjectSet
(ssget) ;"<or" '((0 . "text")) '((0 . "line")) "or>"
  )
  (setq num (sslength selectObjectSet))
  (setq n 0)

  (repeat num

(setq entname (ssname selectObjectSet n))
(setq ent (entget entname))
(cond
 ((= (cdr (assoc 0 ent)) "TEXT")

  (setq entTextvalueList (assoc 1 ent))
  (setq entTextvalue (cdr entTextvalueList))

  (setq insertPoint (cdr (assoc 10 ent)))
  (setq textAngle (cdr (assoc 50 ent)))
  (setq blockinsertPoint
 (polar insertPoint
(+ textAngle (+ pi (/ pi 2)))
(+ val_dimscale (/ val_dimscale 3))
 )
  )
  (setq textAngle_t (* 180 (/ textAngle pi)))

  (setq markSize (car (edwg_mark entTextvalue file_m)))
 )

 ((= (cdr (assoc 0 ent)) "LINE")

  (setq lineStartPoint (cdr (assoc 10 ent)))
  (setq llineEndPoint (cdr (assoc 11 ent)))
  (setq lineLength
 (rtos (distance lineStartPoint llineEndPoint) 2 0)
  )
 )
)
(setq n (+ n 1))
  )
  (command "-insert" "C:/hmgTXT/basicMark/hmg_mark" blockinsertPoint
  val_dimscale textAngle_t lineLength
  markSize entTextvalue
 )
  )
)
  (setvar "attdia" val_attdia)
  (princ)
)



(defun edwg_mark (entTextvalue file_m / fd r1 r2 r3 r4 i) ;

  (setq i 0)
  (setq fd (open file_m "r"))

  (if (= fd nil)
(alert "\n존재하지 않는파일입니다.")
  )

  (while (= i 0)

(setq r1 (read-line fd))

(if (= r1 nil)
 (progn
(setq r4 (list "nothing"))
(setq i 1)
 )
 (progn
(setq r2 (read r1))
(setq r3 (car r2))
 )
)


(if (= r3 entTextvalue)
 (progn
(setq r4 (cdr r2))
(setq i 1)
 )
)

  )
  (close fd)
  r4
)


(defun file_name3 (selectFilevalue / path_m name_m file_m) ;

;(setq path_m "c:/hello/")
  (setq path_m "C:/hmgTXT/")
  (setq name_m selectFilevalue)
  (if (= name_m "")
(setq file_m nil)
(setq file_m (strcat path_m name_m))
  )

  file_m

)



;dcl은 별도로
(defun c:mtest( / a b c)
  (setq a "C:/hmgTXT/basicMark/hmg_mark.txt")
  (setq b "C:/hmgTXT/basicMark/markSizeList.txt")
  (setq c (ssget '((2 . "hmg_mark"))))
  (command "-attext" "o" c "" "s" a b)
  (princ)
  )


basicMarkFile : dialog{
label = "Basic Mark File List";
: list_box {
label = "File List";
key = "selectFile";
}


ok_cancel;
}



2012년 3월 28일 수요일

Set and Return System Variables(시스템변수)


// Get the current value from a system variable
int nMaxSort = System.Convert.ToInt32(Application.GetSystemVariable("MAXSORT"));

// Set system variable to new value
Application.SetSystemVariable("MAXSORT", 100);

2012년 3월 27일 화요일

Calculate Points and Values(포인트와 값 계산)


Get angle from X-axis
(angle)


using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;

[CommandMethod("AngleFromXAxis")]
public static void AngleFromXAxis()
{
  Point2d pt1 = new Point2d(2, 5);
  Point2d pt2 = new Point2d(5, 2);

  Application.ShowAlertDialog("Angle from XAxis: " +
                              pt1.GetVectorTo(pt2).Angle.ToString());
}


Calculate Polar Point
(polar)

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;

static Point2d PolarPoints(Point2d pPt, double dAng, double dDist)
{
  return new Point2d(pPt.X + dDist * Math.Cos(dAng),
                     pPt.Y + dDist * Math.Sin(dAng));
}

static Point3d PolarPoints(Point3d pPt, double dAng, double dDist)
{
  return new Point3d(pPt.X + dDist * Math.Cos(dAng),
                     pPt.Y + dDist * Math.Sin(dAng),
                     pPt.Z);
}

[CommandMethod("PolarPoints")]
public static void PolarPoints()
{
  Point2d pt1 = PolarPoints(new Point2d(5, 2), 0.785398, 12);

  Application.ShowAlertDialog("\nPolarPoint: " +
                              "\nX = " + pt1.X +
                              "\nY = " + pt1.Y);

  Point3d pt2 = PolarPoints(new Point3d(5, 2, 0), 0.785398, 12);

  Application.ShowAlertDialog("\nPolarPoint: " +
                              "\nX = " + pt2.X +
                              "\nY = " + pt2.Y +
                              "\nZ = " + pt2.Z);
}

Find the distance between two points with the GetDistance method
(distance)


using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;

[CommandMethod("GetDistanceBetweenTwoPoints")]
public static void GetDistanceBetweenTwoPoints()
{
  Document acDoc = Application.DocumentManager.MdiActiveDocument;

  PromptDoubleResult pDblRes;
  pDblRes = acDoc.Editor.GetDistance("\nPick two points: ");

  Application.ShowAlertDialog("\nDistance between points: " +
                              pDblRes.Value.ToString());
}




출처
http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html

GetString Method



using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;

[CommandMethod("GetStringFromUser")]
public static void GetStringFromUser()
{
  Document acDoc = Application.DocumentManager.MdiActiveDocument;

  PromptStringOptions pStrOpts = new PromptStringOptions("\nEnter your name: ");
  pStrOpts.AllowSpaces = true;
  PromptResult pStrRes = acDoc.Editor.GetString(pStrOpts);

  Application.ShowAlertDialog("The name entered was: " +
                              pStrRes.StringResult);
}

2012년 3월 26일 월요일

GetPoint Method




using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;

[CommandMethod("GetPointsFromUser")]
public static void GetPointsFromUser()
{
  // Get the current database and start the Transaction Manager
  Document acDoc = Application.DocumentManager.MdiActiveDocument;
  Database acCurDb = acDoc.Database;

  PromptPointResult pPtRes;
  PromptPointOptions pPtOpts = new PromptPointOptions("");

  //public PromptPointOptions(string message)


  // Prompt for the start point
  pPtOpts.Message = "\nEnter the start point of the line: "; //생성자에 넘겨주어도 됌
  pPtRes = acDoc.Editor.GetPoint(pPtOpts);
  Point3d ptStart = pPtRes.Value;


  // Exit if the user presses ESC or cancels the command
  if (pPtRes.Status == PromptStatus.Cancel) return;

  // Prompt for the end point
  pPtOpts.Message = "\nEnter the end point of the line: ";
  pPtOpts.UseBasePoint = true;  //public bool UseBasePoint { set; get; }
  pPtOpts.BasePoint = ptStart;
  pPtRes = acDoc.Editor.GetPoint(pPtOpts);
  Point3d ptEnd = pPtRes.Value;

  if (pPtRes.Status == PromptStatus.Cancel) return;

  // Start a transaction
  using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
  {
      BlockTable acBlkTbl;
      BlockTableRecord acBlkTblRec;

      // Open Model space for write
      acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                   OpenMode.ForRead) as BlockTable;

      acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                      OpenMode.ForWrite) as BlockTableRecord;

      // Define the new line
      Line acLine = new Line(ptStart, ptEnd);
      acLine.SetDatabaseDefaults();

      // Add the line to the drawing
      acBlkTblRec.AppendEntity(acLine);
      acTrans.AddNewlyCreatedDBObject(acLine, true);

      // Zoom to the extents or limits of the drawing
      acDoc.SendStringToExecute("._zoom _all ", true, false, false);

      // Commit the changes and dispose of the transaction
      acTrans.Commit();
  }
}

//두점을 입력받아 선을그리고 줌한다.


출처
http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html

2012년 3월 23일 금요일

hmgScript

개요

내컴퓨터에 있는 dwg파일을 선택해서 일괄 작업을 해주는 CAD script파일을 작성한다.
미리작성한 스크립 파일을 이용해서 선택한 dwg파일의 경로와 목록이 포함됀 스크립 파일을
작성한다.
사전정의됀 스크립선택버튼 = 콤보박스
미등록 사용자정의 스크립파일 선택버튼 = 콤보박스 or 버튼
작성버튼으로 지정됀 폴더에 hmg_script.scr파일을 작성한다.

캐드의 scr명령을 이용해서 작성됀 스크립파일을 실행한다.

createScriptFile class
string dwgfile_location//선택한 도면의 경로
string[] dwgList//선택한도면의 목록
string[] read_scrfile_contants//스크립파일내용 읽기

void create_scr()//작성


2012년 3월 19일 월요일

작업할 폴더를 선택해서 작업할 파일목록을 불러오기


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            folderBrowserDialog1.ShowDialog();
            string aa = folderBrowserDialog1.SelectedPath;

            if (Directory.Exists(aa))
            {
                foreach (string f in Directory.GetFiles(aa))
                {
                    listBox1.Items.Add(f);
                }
            }
           
        }
    }
}

listbox에 지정경로의 파일목록을 불러온다.