Author Topic: ( Challenge ) Change Z value  (Read 8929 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ( Challenge ) Change Z value
« Reply #15 on: March 16, 2006, 12:34:30 PM »
Level: Beginner

Write a program that will change the Z value of selected (D)TEXT.

Example:
Select (D)TEXT to elevate:
Select point with desired elevation:
Oops.  Didn't see the example area completely when I posted my code.  If needs be I can change it, or you can figure out how to change it so it meets your needs.

Hint: Getpoint & caddr
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Bob Wahr

  • Guest
Re: ( Challenge ) Change Z value
« Reply #16 on: March 16, 2006, 12:53:02 PM »
hmmm...looks like I missed that, and the intent, maybe some this
Code: [Select]
Option Explicit
Public Sub PointZAgain()
  Dim varPoint As Variant
  Dim varPick As Variant
  Dim objDtext As AcadText
  Dim dblEndPt(0 To 2) As Double
  On Error GoTo BrokeDown
 
  ThisDrawing.Utility.GetEntity objDtext, varPick, "Pick some text: "
  varPoint = ThisDrawing.Utility.GetPoint(, "Pick a point: ")
  dblEndPt(0) = objDtext.InsertionPoint(0)
  dblEndPt(1) = objDtext.InsertionPoint(1)
  dblEndPt(2) = varPoint(2)
  objDtext.Move objDtext.InsertionPoint, dblEndPt
 
 
Bounce:
 Exit Sub
 
BrokeDown:
  Select Case Err.Number
    Case 13
      ThisDrawing.Utility.Prompt "That's not a piece of text" & vbCrLf
      Err.Clear
      Resume
    Case Else
      Debug.Print Err.Number
      Debug.Print Err.Description
      Err.Clear
      MsgBox "Program fall down go boom!", vbCritical, "Ka-POW"
      GoTo Bounce
  End Select
End Sub

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: ( Challenge ) Change Z value
« Reply #17 on: March 16, 2006, 01:51:48 PM »
Actually, by way of clarification, when you said "point" did you mean mouse click somewhere in space or did you want it done by selecting a point object?
I meant by clicking on an object that has the desired Z value.
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: ( Challenge ) Change Z value
« Reply #18 on: March 16, 2006, 02:02:05 PM »
How about something like these.

Code: [Select]
(defun c:elt ( / aztl ent pt elist)
  ;; change the Z value of the select (d)text entity.
  ;; Thu Mar 16, 2006

  (defun aztl (elist pt)
    ;; aztl = add Z value to list
    ;; elist = entity list
    ;; pt = point list, such as (100.00 200.00 10.0)
    ;;
    ;; returns a list with the Z value from 'pt'
    (list
      (car (cdr (assoc 10 elist)))
      (cadr (cdr (assoc 10 elist)))
      (last pt)
      )
    )

  (if (setq ent (car (entsel "\nSelect Text Item: ")))
    (if (setq pt (getpoint "\nSelect Point: "))
      (progn
        (setq elist (entget ent))

        (setq elist (subst (cons 10 (aztl elist pt))(assoc 10 elist) elist))

        (entmod elist)

        (princ (strcat "Changed to " (rtos (last (assoc 10 elist)))))

        )
      )
    )

  (princ)
  )

(defun c:clt ( / ss)

  (if
    (vl-cmdf "change"
             (setq ss (ssget '((0 . "TEXT"))))
             ""
             "P"
             "Elev"
             (last (getpoint "\nSelect Point: "))
             ""
             )
    (progn
      (princ (strcat (itoa (sslength ss)) " items changed"))
      (setq ss nil)
      )
    )
  (princ)
  )
TheSwamp.org  (serving the CAD community since 2003)

LE

  • Guest
Re: ( Challenge ) Change Z value
« Reply #19 on: March 16, 2006, 02:09:50 PM »
How about something like these.

Code: [Select]
             (last (getpoint "\nSelect Point: ")) ;;;<<<<<<<<
 

Nice, samples

I like that move you did using the last function... quite advanced for a beginner's coder but good.

 :-)

Have fun.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: ( Challenge ) Change Z value
« Reply #20 on: March 16, 2006, 02:14:13 PM »
How about something like these.

Code: [Select]
             (last (getpoint "\nSelect Point: ")) ;;;<<<<<<<<
 

Nice, samples

I like that move you did using the last function... quite advanced for a beginner's coder but good.
Thanks Luis, I'll take that as a compliment.  :-)
TheSwamp.org  (serving the CAD community since 2003)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ( Challenge ) Change Z value
« Reply #21 on: March 16, 2006, 02:23:31 PM »
Looks good to me.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: ( Challenge ) Change Z value
« Reply #22 on: March 16, 2006, 02:50:21 PM »
testing ......... ignore please
TheSwamp.org  (serving the CAD community since 2003)