Jump to content
gsc

How to List attribute tag names and relative angles and distances from 0,0

Recommended Posts

gsc
Posted (edited)

Hi,

 

I want to select an attribute block and create a list of all present attribute objects.

This list should have: the attribute Tag name, angle (in degrees) from X=0, Y=0 to the insertion point of the attribute and the distance from X=0, Y=0 to the insertion point of the attribute

example: ((tagname1, ang1, dist1) (tagname2, ang2, dist2) (tagname3, ang3, dist3))

 

Important Notes:

This block is always a barge (ship) and is always pointing to the true North (positive Y-axis)

The block insertion point (0, 0) is at the Stern side (not necessarily in the center width of the barge)

The barges have a certain amount of anchors (this varies per barge) at Starboard side and at Port side

The insertion points of the attribute objects in the block are located at the center of each anchor

The attribute Tag names are always S1, S2, etc. at Starboard side (right from 0,0) and P1, P2, etc. at Port Side (left from 0,0)

The angle and distance values are relative to the block, not to the world the block is inserted

This information is important because the order of the list must be based on the Tag names: S1, S2, etc.,P1 ,P2, etc.

 

example: ((S1, angS1, distS1) (S2, angS2, distS2) (etc.) (P1, angP1, distP1) (P2, angP2, distP2) (etc.))

 

Can anyone assist me with this?

 

Greetzzz,

 

Gerben

 

 

Edited by gsc

Share this post


Link to post
Share on other sites
dlanorh

An example drawing showing an instance of the block and the required output would help.

Share this post


Link to post
Share on other sites
gsc

I found a piece of code which lists the Tag Names and Attribute(s) coordinate.

But this is the WCS coordinate of the instance I selected and I want the coordinate inside the block

the DXF reference of an ATRRIB does not have a code to get the coordinate inside the block

 

(defun getatt ( blk / enx )
	(if (and (setq blk (entnext blk)) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget blk))))))
		(cons
			(cons
				(cdr (assoc 2 enx))
				(cdr (assoc 10 enx)) ; however this is the WCS coordinate 
			)
			(getatt blk)
		)
	)
)

 

If I have the coordinate of the attribute (inside the block), I can calculate the angle and distance relative to 0,0

 

Share this post


Link to post
Share on other sites
dlanorh

If blk is a block reference then the above code is returning the insertion point, which wouldn't be correct if the attribute was justified anything other than left. You would also need to check the dxf codes 72 and 74. If either of these are non zero you need dxf code 11.

 

 

If blk is a block definition then you need to search for an "ATTDEF" not an "ATTRIB"

 

Yes this is in WCS, so unless i've misunderstood your requirement, the angle and distance are a straight calculation using this point.  You don't need the coordinate inside the block

 

Angle =>  (angle '(0.0 0.0 0.0) wcspt)

Dist    => (distance '(0.0 0.0 0.0) wcspt)

 

If you are looking for the angle and distance from the block references insertion point substitute the insertionpoint for '(0.0 0.0 0.0)

 

If you are in USC then use the (trans) function to convert coords as required.

 

Share this post


Link to post
Share on other sites
gsc

The above code snippet is working for me,  I was thinking too difficult.

I still needed the WCS coordinates as output later in my code.

 

but thanx for your help anyway

Share this post


Link to post
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...