2015年10月13日 星期二

試用3D建模軟體 freecad

A. sketch 繪圖工具列, 需開啟工作檔並選擇 sketch 才可以使用
point: 畫點
line: 畫線
arc: 畫弧線
circle: 畫圓
ellipse: 畫橢圓
polyline: 畫多邊形, (配合'm' 鍵, 轉換不同角度或弧度)
rectangle: 畫四邊形
polygon: 畫等角多邊形(等邊三角形,正方形,正5邊形,正6邊形,正7邊形,正8邊形)
slot: 畫橢圓孔槽
fillet: 兩線之間形成弧線連接
trim: 去除外線
edge link to an external geometry: 定義與外部幾何之連接邊緣線
construct line: 定義輔助線, 將會被隱藏起來

B. 拘束條件與設定工具列, 需選擇物件後(點或線)才可以使用
coincident constrain on the selected item: 將選用的點放到同一位置
fixed a point onto an object: 將點固定在某一物體上(線, 弧線)
vertical constrain: 垂直線拘束
horizontal constrain: 水平線拘束
parallel constrain: 平行線拘束
perpendicular: 垂直線拘束
equility: 相等拘束
symmetry: 對稱拘束
lock: 鎖定拘束
horizontal distance: 設定水平距離
vertical distance:設定垂直距離
distance: 設定兩點距離或線與點之間距離
radius of a circle or an arc: 設定圓或弧的半徑
angle of a line or angle between two lines: 設定線的角度,或兩條線之間的角度
refraction law: 設定折射率 n2/n1

C. 草圖檔案工具列
Create a new sketch: 新增草圖
Edit the selected sketch: 編輯草圖
Close the editing of the sketch: 關閉草圖
View perpendicular to the sketch plane: 垂直平面檢視草圖

D. 平面擠壓(Extrusion)工具列, 需關閉草圖(Sketch Task Close)才可使用.
Map a sketch to a face: 映射平面
Pad a selected sketch: 墊高製造立體物
poket with a selected sketch: 立體挖空面
revolve a selected sketch:環繞製造立體物
groove a selected sketch: 環繞刮除槽, 必須先定義好繪圖平面, 在該平面上繪製刮除面的圖形,
fillet: 圓角
chamfer:斜角
draft
mirror: 鏡射複製
linear pattern: 線性矩陣複製
polar pattern: 環形矩陣複製
multitransform:

E. 視角檢視及測量工具:可自由選擇 6 面視角來檢視繪圖

2015年9月21日 星期一

簡單使用 LibreCAD

1. 修改預設的尺寸單位
Edit -> Application Preferences -> Defaults
若選擇 meter, 則未來開啟檔案時將以'公尺'為單位

2. 修改畫紙上 grid (網點)呈現方式
Edit -> Application Preferences -> Appearance
如果要每 5 個相素距離的網點來呈現畫紙, 可修改成
Minimal Grid Spacing (px): 5
Number of preview entities: 50

3. 修改目前繪圖喜好網點的設定:
Edit-> Current Drawing Preferences -> Grid
修改 X軸及 Y 軸 Grid , 我習慣用 0.1 就好, 比較容易操作

4. 修改尺寸標註呈現方式
Edit-> Current Drawing Preferences -> Dimensions
a.Text Height:文字高度 (插入unicode到繪圖區時,有時中文字會有亂碼出現)
b.Extension line extension:標註線端兩邊之延伸線長
c.extension line offset:從圖形與標註線保留間距,避免圖形與標註線重疊
d.extension line gap:標註線與文字間保留間距,避免文字與標註線重疊
e.arrow size:箭頭符號大小

5. 幾種常用標註線
平面對齊線: Dimension -> Aligned
水平標註線: Dimension -> Horizontal
垂直標註線: Dimension -> Vertical
輻射標註線: Dimension -> Radial
直徑標註線: Dimension -> Diametric
角度標註線: Dimension -> Angular
指示線:Dimension -> Leader

6. 一些繪圖常用指令
a. point : 畫點
b. line   : 畫線
c. arc : 畫弧線
d. polyline: 畫折線
e. rectangle : 畫方形
f. circle  : 畫圓形
上述 line, arc, circle 指令搭配 offset 指令並稍微移動滑鼠便可以繪出平行線或同心弧與同心圓出來

7. 視野放大與平移
za: 繪圖區全視野
zv: 回到上一次視野
zp: 移動滑鼠來平移視野
zw: 拖拉滑鼠指定視野

8. 移動及複製指令之操作:
    a. 預先選好要移動的標的物
    b. 鍵入 mv 指令後按 enter
    c. 指定參考點(點擊按滑鼠右鍵並放開)
    d. 移動到指定點
    e. 選擇是要刪除原始標的物還是要複製一份或多份副本後,再點擊ok並離開
    p.s. 有時須多按幾次ESC鍵,以便跳脫之前預設的命令


2015年8月24日 星期一

利用 overlayfs 將 filesystem.squafs 與 casper-rw 合併成新的 filesystem.squasfs

參考文章:
http://davstott.me.uk/index.php/2013/09/05/ubuntu-13-04-on-a-usb-flash-drive-and-merging-its-persistent-storage.


太實用了! 改天來玩玩,
這樣就無需將 filesystem.squashfs 解壓縮再重裝, 那麼麻煩, 直接用 iso 檔開機, 刪刪減減, 再將他合併, 改成符合自己所適用的作業系統

重點節錄:
假設 persistent storage 放在 /dev/sdb2
sudo su
cd /mnt
mkdir  ro.dir  rw.dir  new.dir
mount /dev/sdb2  rw.dir
mount  -o  loop  filesystem.squashfs  ro.dir
mount  -o  lowerdir=ro.dir,upperdir=rw.dir  -t  overlayfs  none  new.dir
mksquashfs new.dir filesystem.squashfs

chroot new.dir dpkg-query -W --showformat='${Package} ${Version}\n' > filesystem.manifest
printf $(du -sx --block-size=1 new.dir | cut -f1) > filesystem.size

p.s. Linux mint 17.2 已經內建 overlayfs, 可以利用它來運作

2015年8月23日 星期日

Linux mint 無需安裝, 直接使用 LiveCD iso 檔開機, 並讓它擁有永久存放檔案的能力

1. 先規劃好一塊硬碟分區, 因為我的 DRAM 有 8G 空間, 原先 /dev/sdb2 預備當成 swap 分區, 我想 Livecd 應該不需要, 於是我直接將此分區約 2G bytes 空間廢棄, 直接將他改成 ext3 分區來使用, 於是用先 fdisk 將 partition type 0x82 改成 0x83, 接著將他 format 成 ext3 檔案系統(mkfs.ext3 /dev/sdb2). 最後重要的是將他 label 命名成 casper-rw  
tune2fs -L casper-rw /dev/sdb2
或者
e2label /dev/sdb2 casper-rw  
2. 我將整個 cdrom 直接複製到 /dev/sda2/boot/ 目錄內
mount /dev/sda2 /mnt  
dd if=/dev/sr0      of=/mnt/boot/linuxmint172.iso
3. 我使用 Grub 2 的 boot loader, 在 boot option 增加 persistent 字眼
menuentry "Linux Mint 17.2" {  
set root=(hd0,2)  
loopback loop (hd0,2)/boot/linuxmint172.iso
linux        (loop)/casper/vmlinuz boot=casper persistent iso-scan/filename=/boot/linuxmint172.iso ro quiet splash locale=zh_TW.UTF-8    
initrd        (loop)/casper/initrd.lz    
}
4. 大功告成, Linux mint 無需安裝到硬碟中, 只要將 cdrom 的轉成 iso 檔, 複製到 /boot/ 目錄內就好, 且以後任何 linux 系統內任何修改過的資料, 全部都會更新到 /dev/sdb2 中了

2015年8月16日 星期日

試用 linux mint 17.2

重裝 Linux Mint 的方式大致上與重裝 Ubuntu 一樣,
可參考:How to customize Linux Mint live cd/dvd:
http://community.linuxmint.com/tutorial/view/1784
感覺還不錯用, 但是在 zh.TW-UTF8 中文介面, 開啟 terminal, 有些英文字(m 或 w)會與旁邊的字擠成一起, 造成辨識困難.
後來上 google 終於解決了, 只要直接下兩條命令來更改字型便可(特別注意: 千萬不要使用 root 來執行):
gconftool-2 --set /apps/gnome-terminal/profiles/Default/use_system_font --type=boolean false
gconftool-2 --set /apps/gnome-terminal/profiles/Default/font --type string "Liberation Mono 11"
整個操作很像在使用 Windows XP 的感覺, 但無內建中文輸入法, 只好自行再重新封裝加入 gcin:
apt-get install gcin
之後變可以很順利的使用了. 免錢的 OS, 值得推荐.
另外找到 Monaco 字型也可以直接套用, 需先將字型放入 ~/.fonts 或 /usr/share/fonts/truetype 目錄內,並執行 fc-cache -vf 後, 再套用上述兩條命令
gconftool-2 --set /apps/gnome-terminal/profiles/Default/use_system_font --type=boolean false
gconftool-2 --set /apps/gnome-terminal/profiles/Default/font --type=string "Monaco 11"
最後我用 isolinux 製作開機光碟, 將所有檔案放入 isodir 目錄裡, 之後執行 mkisofs:
sudo mkisofs -r -V "Linux Mint 17.2" -cache-inodes -J -l -o linux172.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table isodir
附註1. isolinux 網址: http://www.syslinux.org/wiki/index.php/The_Syslinux_Project
使用 ISOLINUX 時的目錄及檔案結構:
isodir
isodir/isolinux
isodir/isolinux/isolinux.bin
isodir/isolinux/ldlinux.c32
isodir/isolinux/isolinux.cfg
casper
casper/vmlinuz
casper/initrd.lz
casper/filesystem.squashfs
casper/filesystem.manifest
.disk
.disk/casper-uuid-generic
如果是用 GRUB 2 來製作開機光碟, 將所有檔案放入 isodir 目錄裡, 之後再執行 grub-mkrescue
sudo grub-mkrescue -o linux172.iso isodir
附註2. apt-get install xorriso 安裝後, 才可以使用 grub-mkrescue
參考 grub-mkrescue 網址 https://www.gnu.org/software/grub/manual/html_node/Invoking-grub_002dmkrescue.html
使用 GRUB 2 時的目錄及檔案結構:
isodir
isodir/boot
isodir/boot/grub
isodir/boot/grub/grub.cfg
casper
casper/vmlinuz
casper/initrd.lz
casper/filesystem.squashfs
casper/filesystem.manifest
.disk
.disk/casper-uuid-generic

附註3. 如要移除桌面上的 "安裝" 按鈕需要執行在重新封裝(remaster)時將 ubituity 移除
apt-get remove ubiquity

改裝的 Linux mint 17.2 iso 檔案

附註4. 如果要 compile grub-2.0 時出現 stdio.in.h 錯誤訊息, 使用 sed 修改檔案內容變可解決:
sed -i -e ‘/gets is a security/d’ grub-core/gnulib/stdio.in.h








































(initramfs) Uable to find a medium containing a live file system

重裝 Ubuntu 時使用 GRUB 2或 ISOLINUX 當 boot loader 時, CDROM 根目錄 忘記將 .disk 目錄從原公版內複製過來時, 裏面有一個重要的檔案叫作 casper-uuid-generic, 內含當初 build 此公版時所創建的 uuid,如缺乏此檔將造成casper無法從此 CDROM 啟動 Ubuntu linux, 解決的方式是在 boot option 增加 ignore_uuid 便 可, 修改 grub.cfg 如下:

menuentry "Ubuntu Linux from CDROM" {

kernel /casper/vmlinuz.efi boot=casper ignore_uuid

initrd /casper/initrd.lz

}

如果是用 isolinux 則直接在 boot: 下命令

boot: kernel /casper/vmlinuz.efi initrd=/casper/initrd.lz boot=casper ignore_uuid

或修改 isolinux.cfg 內容如下:

label ubuntu

kernel /casper/vmlinuz.efi

append initrd=/casper/initrd.lz boot=casper ignore_uuid

應該可以解決

2013年9月29日 星期日

使用 wkhtmltopdf 將網頁轉成 PDF檔

1. 先下載 wkhtmltopdf: http://code.google.com/p/wkhtmltopdf/
2. 再編輯一串文字檔, 每一行的內容為皆為想要抓取的 URL , 後面緊跟要存成的 PDF 檔名, 將此黨命名為 note.txt
3. note.txt 範例:
http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf-0.9.9-doc.html 0
... 1
以此類推
3. 用 python 寫個 batch 程式, 將上述連結 URL 一行一行轉成 PDF:
url2pdf.py
----------------------------
import os
ff=open('note.txt','rt')
while True:
str=ff.readline()
if not str: break
sss=os.popen('"C:\\Program Files (x86)\\wkhtmltopdf\\wkhtmltopdf" '+str.strip('\n')+'.pdf')
sss.read()
sss.close()
ff.close
-----------------------------
4. 將會獲得 0.pdf, 1.pdf, 2.pdf, ...