how to use ade_odgetfield?

how to use ade_odgetfield?

dwattersAMXH5
Enthusiast Enthusiast
1,992 Views
4 Replies
Message 1 of 5

how to use ade_odgetfield?

dwattersAMXH5
Enthusiast
Enthusiast

hello, 
i am wanting to use ADE_ODGETFIELD to save object data to a list of variables but i am finding very little documentation explaining how to actually use it, how do i point it to the correct OD table? 

in more detail what i want to do is 

 

 

  • select a line 
  • run command 
    • get an object data field for that line (field is "FQN_ID") and save the field as a variable 
      *in full transparency i really need to build this in a foreach that way if multiple lines are selected (they would be on top of each other but have different "FQN_ID" fields) it will get the field from both (all?) lines and build a list that i can then call with a variable
    • create multi-leader 
      • pause for start and end points 
      • call in variable to populate text


 any help i can get on understanding how to use ADE_ODGETFIELD and store it to a variable would be greatly appreciated 

 

thanks.

0 Likes
Accepted solutions (1)
1,993 Views
4 Replies
Replies (4)
Message 2 of 5

dwattersAMXH5
Enthusiast
Enthusiast
(defun c:mlfq (/)
(setq ent (car (entsel "\nSelect line")))
(setq lst (ade_odgettables ent))
(setq fqnid (ade_odgetfield ent lst "FQN_ID" O))
(command "mleader" pause pause fqnid)
)

i've gotten here in testing but the leader is coming back blank (no text where var fqnid should be supplying the information out of the od field) 

0 Likes
Message 3 of 5

dwattersAMXH5
Enthusiast
Enthusiast
(defun c:mlfq (/)
  (princ "\nSelect SOURCE object: ")
  (setq source_obj (car (entsel)))
  (if (null source_obj)
    (prompt "\nNo source object selected.")
    (progn
      (setq lst (ade_odgettables source_obj))
      (setq fqnid (ade_odgetfield source_obj lst "FQN_ID" O))
      (command "mleader" pause pause fqnid)
    )

    )
)

or  this - to catch if the object isn't being grabbed. still not getting object data across to leader 

0 Likes
Message 4 of 5

CodeDing
Advisor
Advisor
Accepted solution

@dwattersAMXH5,

 

It's not perfect, but this should get you on the right track!

 

Best,

~DD

 

(defun c:mlfq ( / ss e tbl tmp fqnid)
;prompt before ssget because you cannot add prompt within ssget
(prompt "\nSelect Entities with Object Data: \n")
;if selection set (ss) has objects
(if (setq ss (ssget))
(progn
  	;temporary counting variable
  	(setq tmp 0)
  	;repeat for number of objects in ss
	(repeat (sslength ss)
	  	;get entity name from position in ss (tmp is position)
		(setq e (ssname ss tmp))
	  	;get first table in OD
	  	(setq tbl (car (ade_odgettables e)))
	  	;check if field returns a value, store as variable
	  	(if (setq fqnid (ade_odgetfield e tbl "FQN_ID" 0))
		(progn
		  	;zoom to entity for easy multileader insertion
			(command "zoom" "o" e "")
		  	;add mleader that user will insert, provide default text
		  	(command "_.mleader" pause pause fqnid)
		));progn/if
	  	;increment temporary count
	  	(setq tmp (1+ tmp))
	);repeat
);progn
;else
;let user know if nothing selected
(prompt "\nNothing Selected.")
);if
(princ);finish quietly
);defun

 

0 Likes
Message 5 of 5

dwattersAMXH5
Enthusiast
Enthusiast

thank you! 

 

 

also i found my problem with my code being a miss-type at 

     (setq fqnid (ade_odgetfield source_obj lst "FQN_ID" O))

O not being 0 (zero) (what can i say - still getting used to a new keyboard lol) 

 

 

 

 

0 Likes