magnus2005 Posted September 12, 2015 Share Posted September 12, 2015 (edited) Hello, I am wondering if it is possible to do macro: 1.start module 2. Drawing polyline in auto cad (like normal you draw poly in cad using pline comannd) 3. End drawing poly 4. Take coords of new poly and change colors. It is example algorithm but its show you how I want to create polyline. Instead of put poly using coords from variable I want normally draw poly to use function i.e orto or sample to see shape. My program will be to draw poly and after poly will be preparated to draw. It is possible to do it way I want? Edited September 12, 2015 by magnus2005 Quote Link to comment Share on other sites More sharing options...
SEANT Posted September 12, 2015 Share Posted September 12, 2015 It may be possible to simulate the real-time, dynamic feedback that you described by continually adding lines, and using GetPoint with the previous Line’s endpoint as a Base. At the end, the lines could be erased and the proper polyline created. One major drawback would be if you wanted to account for arcs – I don’t think the Arc/Bulge creation sequence of the polyline command could be re-created via VBA. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 13, 2015 Share Posted September 13, 2015 If you have a list of points ((12 34)(56 78) .... this will draw a pline ; list is coordsxy (command "_PLINE") (while (= (getvar "cmdactive") 1 ) (repeat (length co-ordsxy) (command (nth (setq x (+ x 1)) co-ordsxy)) ) Quote Link to comment Share on other sites More sharing options...
magnus2005 Posted September 13, 2015 Author Share Posted September 13, 2015 I know how to create polyline if I have list of point. Thing is I want to run command pline so that user can draw poly. Getting point is not enough for me, I need to see what I am drawing. Getting points is useless because you can choose point about different coordinations i.e I want to draw vertical line but second point choosen has different x than first. Quote Link to comment Share on other sites More sharing options...
SEANT Posted September 13, 2015 Share Posted September 13, 2015 My VBA is rusty so I'm not going to take this very far (only as far as drawing the lines). Here is some code illustrating what I suggested above. Sub Example_AddLine() Dim strPrompt As String Dim dblPt() As Double Dim dblNextPt() As Double Dim blnTrue As Boolean Dim lineObj As AcadLine strPrompt = "Get First Point: " blnTrue = True With ThisDrawing.Utility On Error Resume Next dblPt = .GetPoint(, strPrompt) If Err.Number <> 0 Then Exit Sub Do While blnTrue = True strPrompt = "Get Next Point: " dblNextPt = .GetPoint(dblPt, strPrompt) If Err.Number <> 0 Then blnTrue = False Set lineObj = ThisDrawing.ModelSpace.AddLine(dblPt, dblNextPt) dblPt = dblNextPt Loop On Error GoTo 0 End With End Sub The GetPoint method will respect the Ortho setting during input, though not if an object snap is used. You would have to code your own logic if that combination is to be addressed. See screencast of code in action. https://screencast.autodesk.com/main/details/46bb9fdd-e8b6-49c7-91de-f7ea2f113ef7 Quote Link to comment Share on other sites More sharing options...
magnus2005 Posted September 13, 2015 Author Share Posted September 13, 2015 Yes, it is a kind of solution but still it isnt exactly what I meant. I cannot put lenght of line. Quote Link to comment Share on other sites More sharing options...
SEANT Posted September 13, 2015 Share Posted September 13, 2015 I'm sorry I wasted your time. Quote Link to comment Share on other sites More sharing options...
magnus2005 Posted September 14, 2015 Author Share Posted September 14, 2015 (edited) I'm sorry but you missunderstand me. Your advice is very helpfull and thank you for it. But I 'm disappointed to vba cannot do that. Edited September 14, 2015 by magnus2005 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.