Jump to content

Is there anyway to move/copy/offset objects by selecting a text value?


Recommended Posts

Posted

I guess you could link the text to the line with a hyperlink or select nearest. but its not saving any clicks so why not just select the line?

Posted

I'm not sure what you're trying to do, but if you want click and drag to edit capability use dynamicblocks.  

Posted

Reading your question as you write it, yes you can.

 

If I read it correctly, you want to select a text, then an object and offset or move that object by the value of the text?

 

How is your LISP programming? 

You can use something like

(setq MyText (entget(car (entsel "Select Text"))))

or

(setq MyText (entget (ssname (ssget "_+.:E:S"  '((0 . "TEXT"))) 0)))

 

to get the text definition, and then use 

 

(setq MyTextVal (assoc 1 MyText))

 

To extract the value of the text

 

The text value should be returned as a string, not a number. You can change a string to a number using atoi and after that apply that to the object you want to move, copy or offset. You might want to do a check that the text is a number before you do atoi else it will be an error

 

Is that enough to give you a clue and help you work out what to do?

  • Like 1
Posted
1 minute ago, Steven P said:

If I read it correctly, you want to select a text, then an object and offset or move that object by the value of the text?

 

How is your LISP programming? 

Yes, that's I want to do.

I'm noob in this field, trying to learn something by seeing others code

Posted
1 hour ago, faizur said:

I'm noob in this field, trying to learn something by seeing others code

 

Best way to learn is by having a go....

 

Taking it step by step then, start by making a LISP file - you should be able to do that and copy this into it which will allow you t select text and get the value, then can take the next step and you'll learn as you go along:

 

(defUn c:test ( / Mytext MyTextVal ) ;;define the LISP routine. After the / are local variables used only in this LISP
  (princ "Select Text") ;; princ - puts a message in the command line
  (setq MyText (entget (ssname (ssget "_+.:E:S"  '((0 . "TEXT"))) 0))) ;; Select a selection, the other parts linit this here to 1 tect object
  (setq MyTextVal (cdr (assoc 1 MyText))) ;; get the text from the selected text above
  MyTextVal ;;returns the text value from this LISP
) ;; end the routine

 

 

See if this works for you then can do the next step

  • Like 2
Posted

If you made it a leader then you could do with 1 pick so long as end of arrow is on line. You can get the pt and the text from the properties of a  leader

Posted
11 hours ago, Steven P said:

 

Best way to learn is by having a go....

 

Taking it step by step then, start by making a LISP file - you should be able to do that and copy this into it which will allow you t select text and get the value, then can take the next step and you'll learn as you go along:

 

(defUn c:test ( / Mytext MyTextVal ) ;;define the LISP routine. After the / are local variables used only in this LISP
  (princ "Select Text") ;; princ - puts a message in the command line
  (setq MyText (entget (ssname (ssget "_+.:E:S"  '((0 . "TEXT"))) 0))) ;; Select a selection, the other parts linit this here to 1 tect object
  (setq MyTextVal (cdr (assoc 1 MyText))) ;; get the text from the selected text above
  MyTextVal ;;returns the text value from this LISP
) ;; end the routine

 

 

See if this works for you then can do the next step

image.png.020d6e137ef8d9e357c662725aa3e85b.png

It's working and geting the text value

Posted

Select text, select line, ok now the buggy part does offset go left or right ? If its always away from text then easy.

 

(defun c:wow ( / ent off pt ent2 pt2)
(setq ent (entget (car (entsel "\nPick text "))))
(setq off (atof (cdr (assoc 1 ent))))
(setq pt (cdr (assoc 10 ent)))
(setq ent2 (entsel "\nPick line "))
(setq pt2 (cadr ent2))
(command "offset" off ent2 (polar pt2 (angle pt pt2) 10.0) "") ; increase 10 if problems dummy point
)
(c:wow)

 

 

  • Like 1
Posted
3 hours ago, BIGAL said:

Select text, select line, ok now the buggy part does offset go left or right ? If its always away from text then easy.

 

(defun c:wow ( / ent off pt ent2 pt2)
(setq ent (entget (car (entsel "\nPick text "))))
(setq off (atof (cdr (assoc 1 ent))))
(setq pt (cdr (assoc 10 ent)))
(setq ent2 (entsel "\nPick line "))
(setq pt2 (cadr ent2))
(command "offset" off ent2 (polar pt2 (angle pt pt2) 10.0) "") ; increase 10 if problems dummy point
)
(c:wow)

 

 

Thanks man, it works ❤️

Posted
13 minutes ago, faizur said:

the buggy part does offset go left or right

Yes. But the code offset works only below the text

Posted

Not sure your question, maybe look at comment about changing value 10 in code.

Posted
On 10/6/2022 at 6:57 AM, BIGAL said:

changing value 10 in code

10 to what?  for left/right offset

Posted (edited)

Post more detail what your asking for, my crystal ball is out being polished.

Edited by BIGAL
  • Funny 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...