Author Topic: advanced challenge!  (Read 6715 times)

0 Members and 1 Guest are viewing this topic.

Ron Heigh

  • Guest
advanced challenge!
« on: December 03, 2004, 09:34:31 AM »
devise a way to draw a line such that you can define an end extension for the start point and end point.  The nodes must remain at the original location, while the visible part can extend past/run short of the node.

Code: [Select]

original
o----------------o

with extensions
----o---------o------

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
advanced challenge!
« Reply #1 on: December 03, 2004, 09:53:42 AM »
Ok, for some reason I cannot fully understand what you are looking for, how about a picture of the before and after
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
advanced challenge!
« Reply #2 on: December 03, 2004, 10:02:31 AM »
I assume the line with extensions is actually three lines.
What are the nodes? Point Objects, Blocks?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Ron Heigh

  • Guest
advanced challenge!
« Reply #3 on: December 03, 2004, 10:18:02 AM »
image drawing a simple line from a to b.
the work points are still at a and b, but the line is longer/shorter.
double click on the line to access the extension values and modify them.
now the workpoints are still at a & b, but the line changes again.

I imaging the workpoints would need to be points, not nodes.
and the line would have to be bound to the with xdata or a persistant reactor of some sort.

whdjr

  • Guest
advanced challenge!
« Reply #4 on: December 03, 2004, 10:44:57 AM »
I've got my answer.  Are we allowed to post or do we have to wait 24 hours?

Ron Heigh

  • Guest
advanced challenge!
« Reply #5 on: December 03, 2004, 11:21:43 AM »
Post away.

whdjr

  • Guest
advanced challenge!
« Reply #6 on: December 03, 2004, 11:55:04 AM »
Here is my answer although it is not associative as you indicated on a later post.
Code: [Select]
;;;Devise a way to draw a line such that you can define an end
;;;extension for the start point and end point. The nodes must
;;;remain at the original location, while the visible part can
;;;extend past/run short of the node.
(defun c:challenge (/ pt1 pt2 pdm pds dist ang pt3 pt4)
  (if (not
(and (setq pdm (getvar "PDMODE")
  pds (getvar "PDSIZE")
    )
    (not (initget 1))
    (setq pt1 (getpoint "\nSelect Startpoint:  "))
    (not (initget 1))
    (setq pt2 (getpoint pt1 "\nSelect Endpoint:  "))
    (setvar "PDSIZE" 0)
    (setvar "PDMODE" 34)
    (vl-cmdf "_.point" pt1)
    (vl-cmdf "_.point" pt2)
    (not (initget (+ 1 2)))
    (setq dist
   (getreal
     "\nEnter positive(+) distance to extend line or negative(-) distance to shorten line:"
   )
    )
    (setq ang (angle pt1 pt2))
    (setq pt3 (polar pt1 ang (* -1 dist)))
    (setq pt4 (polar pt2 ang dist))
    (entmake (list '(0 . "LINE") (cons 10 pt3) (cons 11 pt4)))
    (setvar "PDMODE" pdm)
    (setvar "PDSIZE" pds)
)
      )
    (princ "\nError:  Function Cancelled!  ")
  )
  (princ)
)

Ron Heigh

  • Guest
advanced challenge!
« Reply #7 on: December 03, 2004, 12:04:14 PM »
Nice program, it doesn't satisfy the challenge though.
You've moved the nodes, plus numerous other criteria.

whdjr

  • Guest
advanced challenge!
« Reply #8 on: December 03, 2004, 12:13:14 PM »
no I didn't.  I extended or shortened the line just like you asked.

CADaver

  • Guest
advanced challenge!
« Reply #9 on: December 03, 2004, 12:21:54 PM »
Quote from: Ron Heigh
Nice program, it doesn't satisfy the challenge though.
You've moved the nodes, plus numerous other criteria.
You want the line to display longer (or shorter) than it's defined endpoints??

Ron Heigh

  • Guest
advanced challenge!
« Reply #10 on: December 03, 2004, 12:33:19 PM »
Quote
imagine drawing a simple line from a to b.
the work points are still at a and b, but the line is longer/shorter.
double click on the line to access the extension values and modify them.
now the workpoints are still at a & b, but the line changes again.

I imaging the workpoints would need to be points, not nodes.
and the line would have to be bound to the with xdata or a persistant reactor of some sort.


Did you read this post?
This is why I said Advanced.
It isn't an easy feat.

CADaver

  • Guest
advanced challenge!
« Reply #11 on: December 03, 2004, 01:13:04 PM »
Quote from: Ron Heigh
Quote
imagine drawing a simple line from a to b.
the work points are still at a and b, but the line is longer/shorter.
double click on the line to access the extension values and modify them.
now the workpoints are still at a & b, but the line changes again.

I imaging the workpoints would need to be points, not nodes.
and the line would have to be bound to the with xdata or a persistant reactor of some sort.


Did you read this post?
This is why I said Advanced.
It isn't an easy feat.


Yes I read your post.  It made no sense... still doesn't.  Autocad has no term "workpoint", and points are nodes.  And how can the line change "again" when you haven't cahnged it in the first place.

So my question remains unanswered, "You want the line to display longer (or shorter) than it's defined endpoints??"

Ron Heigh

  • Guest
advanced challenge!
« Reply #12 on: December 03, 2004, 01:25:27 PM »
Good call.  I'm using terms from steel detailing I guess.

Quote
"You want the line to display longer (or shorter) than it's defined endpoints??"


Correct.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
advanced challenge!
« Reply #13 on: December 03, 2004, 03:55:37 PM »
What language do we have to write it in?

Can I use VBA ?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Ron Heigh

  • Guest
advanced challenge!
« Reply #14 on: December 03, 2004, 04:06:16 PM »
I 'm only interested in the result, not how you got there.
The more creative the better as far as I'm concerned.
Good luck.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
advanced challenge!
« Reply #15 on: December 03, 2004, 04:45:27 PM »
ThisDrawing code

Code: [Select]

Private Sub AcadDocument_BeginDoubleClick(ByVal PickPoint As Variant)
 Dim AcadObj As AcadEntity
 Dim AcadDim As AcadDimension
 Dim SelSet As AcadSelectionSet
 
 PickPoint = ThisDrawing.Utility.TranslateCoordinates(PickPoint, acWorld, acUCS, False)
 
 On Error GoTo ClearOut
 Set SelSet = ThisDrawing.SelectionSets.Add("ClickReactor")
 SelSet.SelectAtPoint PickPoint
 For Each AcadObj In SelSet
  If AcadObj.ObjectName = "AcDbLine" Then
   Module1.UpDate AcadObj
  End If
 Next AcadObj
ClearOut:
ThisDrawing.SelectionSets.Item("ClickReactor").Delete
End Sub





Module1 Code

Code: [Select]

Sub ChallengeLine()
 Dim Point1 As AcadPoint
 Dim Point2 As AcadPoint
 Dim MyLine As AcadEntity
 Dim IPoint(2) As Double
 Dim BlockExists As Boolean
 Dim XDType(0 To 2) As Integer
 Dim XDValue(0 To 2) As Variant
 
 XDType(0) = 1001
 XDType(1) = 1005
 XDType(2) = 1005
 
 XDValue(0) = "ChallengeLine"
 PT1 = ThisDrawing.Utility.GetPoint
 PT2 = ThisDrawing.Utility.GetPoint
 
 Set MyLine = ThisDrawing.ModelSpace.AddLine(PT1, PT2)
 Set Point1 = ThisDrawing.ModelSpace.AddPoint(PT1)
 Set Point2 = ThisDrawing.ModelSpace.AddPoint(PT2)
 
 XDValue(1) = Point1.Handle
 XDValue(2) = Point2.Handle
 MyLine.SetXData XDType, XDValue
 
 XDValue(1) = MyLine.Handle
 XDValue(2) = "00"
 Point1.SetXData XDType, XDValue
 Point2.SetXData XDType, XDValue
End Sub

Function UpDate(Object As AcadLine)
 Dim XDType As Variant
 Dim XDValue As Variant
 Dim MaxAmt As Integer
 Dim Point1 As AcadPoint
 Dim Point2 As AcadPoint
 Dim EndOffSet As Variant
 
 MaxAmt = -1
 
 Object.GetXData "ChallengeLine", XDType, XDValue
 
 On Error GoTo Skip
 MaxAmt = UBound(XDType)
Skip:
 If MaxAmt > -1 Then
 For X = 0 To UBound(XDType) - 1
  If XDType(X) = 1005 Then
   Set Point1 = ThisDrawing.HandleToObject(XDValue(X))
   Set Point2 = ThisDrawing.HandleToObject(XDValue(X + 1))
  End If
 Next X
 
 EndOffSet = Interaction.InputBox("Enter endpoint offset distance", "Challenge Line")
 Object.StartPoint = ThisDrawing.Utility.PolarPoint(Point1.Coordinates, Object.Angle, -EndOffSet)
 Object.EndPoint = ThisDrawing.Utility.PolarPoint(Point2.Coordinates, Object.Angle, EndOffSet)

 End If
 
End Function




Enjoy
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Ron Heigh

  • Guest
advanced challenge!
« Reply #16 on: December 03, 2004, 06:20:54 PM »
Very nice Keith.
Is that XData?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
advanced challenge!
« Reply #17 on: December 04, 2004, 12:17:51 AM »
Yep ... It took me about 15 minutes to put it together ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Ron Heigh

  • Guest
advanced challenge!
« Reply #18 on: December 04, 2004, 01:47:03 PM »
Now I really want to learn XData.
Pretty cool stuff.

Ron Heigh

  • Guest
advanced challenge!
« Reply #19 on: December 04, 2004, 01:47:29 PM »
wow, 200 posts.
why am I still a newt?

Ron Heigh

  • Guest
advanced challenge!
« Reply #20 on: December 04, 2004, 01:47:52 PM »
never mind.  Bull Frogs rule.
ribbit.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
advanced challenge!
« Reply #21 on: December 04, 2004, 02:15:53 PM »
XData is simply the means by which you can store specific information in the entity itself. In this program example, it is the handles of the attached points. I was thinking of making the line and the points work in conjunction with one another, for example, if you grab a point and move it, the line follows, or if you extend a line, the point follows, maintaining the extension of the line as defined by the xdata
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie