Advertisement
Guest User

AutoCAD

a guest
Jun 20th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Visual Basic
  2. Forma1 -> Kruznica,sa Korakom 2 i BrojKruznica je 3
  3. Manage -> Visual Basic Editor -> Insert -> UserForm -> TextBox... -> 2xKlik -> Procedura
  4.  
  5. Private Sub CommandButton1_Click()
  6.     Dim Centar(0 To 2) As Double
  7.     Dim Obj As Variant
  8.    
  9.     Obj = Split(Me.TextBox1.Text, ",")
  10.  
  11.    
  12.     Centar(0) = CDbl(Obj(0))
  13.     Centar(1) = CDbl(Obj(1))
  14.     Centar(2) = CDbl(Obj(2))
  15.    
  16.    
  17.     Dim Radijus As Double
  18.     Radijus = CDbl(Me.TextBox2.Text)
  19.    
  20.     Dim Korak As Double
  21.     Korak = CDbl(Me.TextBox3.Text)
  22.    
  23.     Dim Broj As Double
  24.     Broj = CInt(Me.TextBox4.Text)
  25.    
  26.     Dim circ As AcadCircle
  27.    
  28.     Dim i As Integer
  29.     For i = 0 To (Broj - 1)
  30.     Set circ = ThisDrawing.ModelSpace.AddCircle(Centar, Radijus + i * Korak)
  31.     circ.Update
  32.     Next i
  33.    
  34.     Unload Me
  35.  
  36. End Sub
  37.  
  38. Krug i MaliKrug
  39. Private Sub CommandButton1_Click()
  40.     Dim Centar(0 To 2) As Double
  41.     Dim Radijus As Double
  42.    
  43.     Dim obj As Variant
  44.     obj = Split(Me.TextBox1.Text, ",")
  45.    
  46.     Centar(0) = CDbl(obj(0))
  47.     Centar(1) = CDbl(obj(1))
  48.     Centar(2) = CDbl(obj(2))
  49.    
  50.     Radijus = CDbl(Me.TextBox2)
  51.    
  52.    
  53.     Dim circ As AcadCircle
  54.     Set circ = ThisDrawing.ModelSpace.AddCircle(Centar, Radijus)
  55.     circ.Update
  56.    
  57.     Dim r As Double
  58.     r = CDbl(Me.TextBox3)
  59.    
  60.     Dim Broj As Integer
  61.     Broj = CInt(Me.TextBox4)
  62.    
  63.     Dim udaljenost As Double
  64.     udaljenost = Radijus + r
  65.    
  66.     Dim MaliCentar(0 To 2) As Double
  67.     MaliCentar(0) = Centar(0) + udaljenost
  68.     MaliCentar(1) = Centar(1)
  69.     MaliCentar(2) = Centar(2)
  70.    
  71.    
  72.     Dim malikrug As AcadCircle
  73.     Set malikrug = ThisDrawing.ModelSpace.AddCircle(MaliCentar, r)
  74.     malikrug.Update
  75.    
  76.    
  77.     Unload Me
  78.    
  79. End Sub
  80. Krug + Okruzen Krugovima
  81. Private Sub CommandButton1_Click()
  82.     Dim Centar(0 To 2) As Double
  83.     Dim Radijus As Double
  84.    
  85.     Dim obj As Variant
  86.     obj = Split(Me.TextBox1.Text, ",")
  87.    
  88.     Centar(0) = CDbl(obj(0))
  89.     Centar(1) = CDbl(obj(1))
  90.     Centar(2) = CDbl(obj(2))
  91.    
  92.     Radijus = CDbl(Me.TextBox2)
  93.    
  94.    
  95.     Dim circ As AcadCircle
  96.     Set circ = ThisDrawing.ModelSpace.AddCircle(Centar, Radijus)
  97.     circ.Update
  98.    
  99.     Dim r As Double
  100.     r = CDbl(Me.TextBox3)
  101.    
  102.     Dim Broj As Integer
  103.     Broj = CInt(Me.TextBox4)
  104.    
  105.     Dim udaljenost As Double
  106.     udaljenost = Radijus + r
  107.    
  108.    
  109.     Dim MaliCentar(0 To 2) As Double
  110.     MaliCentar(0) = Centar(0) + udaljenost
  111.     MaliCentar(1) = Centar(1)
  112.     MaliCentar(2) = Centar(2)
  113.    
  114.    
  115.     Dim ugao As Double
  116.     ugao = 360#
  117.     Dim PI As Double
  118.     PI = 4# * Math.Atn(1#)
  119.     ugao = (2# * PI) / Broj
  120.    
  121.    
  122.     Dim malikrug As AcadCircle
  123.    
  124.     Set malikrug = ThisDrawing.ModelSpace.AddCircle(MaliCentar, r)
  125.     malikrug.Update
  126.    
  127.      Call malikrug.ArrayPolar(Broj, ugao, Centar)
  128.    
  129.     Unload Me
  130.    
  131. End Sub
  132.  
  133. Visual Lisp
  134. ;|  (command "CIRCLE"
  135.     (list (+(+ (nth 0 centar) poluprecnik) r)
  136.         (nth 1 centar)
  137.         (nth 2 centar)
  138.         )
  139.         r
  140.         ""
  141.        )
  142.  
  143.   (command "CIRCLE"
  144.        (list (nth 0 centar)
  145.           (+(+ (nth 1 centar) poluprecnik) r)
  146.          (nth 2 centar)
  147.          )
  148.          r
  149.          "")
  150.  
  151.    (command "CIRCLE"
  152.        (list (nth 0 centar)
  153.           -(+(+ (nth 1 centar) poluprecnik) r)
  154.          (nth 2 centar)
  155.          )
  156.          r
  157.          "")|;
  158.  
  159. (defun fun (/ centar poluprecnik broj r brojac ugao udaljenost)
  160.  ; unos centra poluprecnika broja i radijusa
  161.   (setq centar (getpoint "\nIzaberite centar"))
  162.   (setq poluprecnik (getreal "\nIzaberite poluprecnik:"))
  163.   (setq broj (getint "\nIzaberite broj:"))
  164.   (setq r (getreal "Izaberite radijus:"))
  165.  
  166.   (command "CIRCLE" centar poluprecnik "")
  167.   (setq brojac 0)
  168.   (setq ugao (/(* (pi)2)broj))
  169.   (setq udaljenost  (+(+ poluprecnik)r) )
  170.   (repeat broj
  171.   (command "CIRCLE" (polar centar (* brojac ugao) udaljenost) r "")
  172.  
  173.     (setq brojac (+ (brojac 1)) )
  174.     )
  175.  )  
  176.  
  177.  
  178. ;|(defun fun (/ centar poluprecnik broj r brojac ugao udaljenost)
  179.  ; unos centra poluprecnika broja i radijusa
  180.   (setq centar (getpoint "\nIzaberite centar"))
  181.   (setq poluprecnik (getreal "\nIzaberite poluprecnik:"))
  182.   (setq broj (getint "\nIzaberite broj:"))
  183.   (setq r (getreal "Izaberite radijus:"))
  184.  
  185.   (command "CIRCLE" centar poluprecnik)
  186. ;dodamo po x
  187. (command "CIRCLE"
  188.     (list (+(+ (nth 0 centar) poluprecnik) r)
  189.         (nth 1 centar)
  190.         (nth 2 centar)
  191.         )
  192.         r
  193.         ""
  194.        )
  195. ;dodamo po y
  196.   (command "CIRCLE"
  197.        (list (nth 0 centar)
  198.           (+(+ (nth 1 centar) poluprecnik) r)
  199.          (nth 2 centar)
  200.          )
  201.          r
  202.          "")
  203. ;oduzmemo po y
  204.    (command "CIRCLE"
  205.        (list (nth 0 centar)
  206.          ( -(+(+ (nth 1 centar) poluprecnik) r))
  207.          (nth 2 centar)
  208.          )
  209.          r
  210.          "")
  211. ;oduzmemo po x
  212.   (command "CIRCLE"
  213.     (list  (-(+(+ (nth 0 centar) poluprecnik) r))
  214.         (nth 1 centar)
  215.         (nth 2 centar)
  216.         )
  217.         r
  218.         ""
  219.        )
  220.  
  221. ) |;
  222.  
  223. RADI
  224. (defun fun ( / centar poluprecnik broj r i ugao udaljenost )
  225.  
  226.   (setq centar (getpoint "\nIzaberite centar"))
  227.   (setq poluprecnik (getreal "\nIzaberite poluprecnik:"))
  228.   (setq broj (getint "\nIzaberite broj:"))
  229.   (setq r (getreal "Izaberite radijus:"))
  230.  
  231.   (command "CIRCLE" centar poluprecnik "\n")
  232.  
  233.   (setq i 0)
  234.   (setq ugao (/ (* 2 pi) broj))
  235.   (setq udaljenost (+ poluprecnik r))
  236.   (repeat broj
  237.     (command "CIRCLE" (polar centar (* i ugao) udaljenost) r "\n")
  238.     (setq i (+ i 1))
  239.     )
  240. )    
  241.  
  242. Pravogaonik RectChamfer
  243. Public Sub RectChamfer(x As Double, y As Double, a As Double, b As Double, c1 As Double, c2 As Double)
  244.  
  245. Dim p(0 To 15) As Double
  246. p(0) = x + c1: p(1) = y: p(2) = x: p(3) = y + c2: p(4) = x: p(5) = y + b - c2: p(6) = x + c1: p(7) = y + b: p(8) = x + a - c1: p(9) = y + b: p(10) = x + a: p(11) = y + b - c2: p(12) = x + a: p(13) = y + c1: p(14) = x + a - c2: p(15) = y
  247.  
  248. Set pline = ThisDrawing.ModelSpace.AddLightWeightPolyline(p)
  249. pline.Closed = True
  250. pline.Update
  251. End Sub
  252.  
  253. Sub Main()
  254. Call RectChamfer(0, 0, 20, 10, 3, 3)
  255. End Sub
  256.  
  257.  
  258. RecFillet Mirela.De
  259. Public Sub RectFillet(x As Double, y As Double, a As Double, b As Double, f As Double)
  260.  
  261. Dim p(0 To 15) As Double
  262. p(0) = x + f: p(1) = y: p(2) = x: p(3) = y + f: p(4) = x: p(5) = y + b - f: p(6) = x + f: p(7) = y + b: p(8) = x + a - f: p(9) = y + b: p(10) = x + a: p(11) = y + b - f: p(12) = x + a: p(13) = y + f: p(14) = x + a - f: p(15) = y
  263.  
  264. Set pline = ThisDrawing.ModelSpace.AddLightWeightPolyline(p)
  265. pline.Closed = True
  266.  
  267. Dim pi As Double
  268. pi = 4# * Math.Atn(1#)
  269. pline.SetBulge 0, -Math.Tan(pi / 8)
  270. pline.SetBulge 2, -Math.Tan(pi / 8)
  271. pline.SetBulge 4, -Math.Tan(pi / 8)
  272. pline.SetBulge 6, -Math.Tan(pi / 8)
  273. pline.Update
  274.  
  275.  
  276. End Sub
  277.  
  278. Sub Main()
  279. Call RectFillet(0, 0, 20, 10, 3)
  280. End Sub
  281.  
  282. Zadatak Tastatura
  283. Public Sub RectFillet(x As Double, y As Double, a As Double, b As Double, f As Double)
  284.  
  285. Dim p(0 To 15) As Double
  286. p(0) = x + f: p(1) = y: p(2) = x: p(3) = y + f: p(4) = x: p(5) = y + b - f: p(6) = x + f: p(7) = y + b: p(8) = x + a - f: p(9) = y + b: p(10) = x + a: p(11) = y + b - f: p(12) = x + a: p(13) = y + f: p(14) = x + a - f: p(15) = y
  287.  
  288. Set pline = ThisDrawing.ModelSpace.AddLightWeightPolyline(p)
  289. pline.Closed = True
  290.  
  291. Dim pi As Double
  292. pi = 4# * Math.Atn(1#)
  293. pline.SetBulge 0, -Math.Tan(pi / 8)
  294. pline.SetBulge 2, -Math.Tan(pi / 8)
  295. pline.SetBulge 4, -Math.Tan(pi / 8)
  296. pline.SetBulge 6, -Math.Tan(pi / 8)
  297. pline.Update
  298.  
  299.  
  300. End Sub
  301.  
  302.  
  303. Public Sub Keyboard(columns As Integer, rows As Integer, width As Double, height As Double, hspace As Double, vspace As Double)
  304. Dim i As Integer, j As Integer
  305. For i = 0 To rows - 1
  306. For j = 0 To columns - 1
  307. Dim x As Double, y As Double, f As Double
  308.  
  309. If width < height Then f = width / 10 Else f = height / 10
  310.  
  311. x = j * (width + hspace)
  312. y = i * (height + vspace)
  313. Call RectFillet(x, y, width, height, f)
  314. Next
  315. Next
  316.  
  317. End Sub
  318.  
  319.  
  320. Sub Main()
  321. Call Keyboard(12, 4, 10, 12, 2, 4)
  322. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement