Copying Object data to Property Sets

Copying Object data to Property Sets

gunther.groenestein
Participant Participant
4,799 Views
16 Replies
Message 1 of 17

Copying Object data to Property Sets

gunther.groenestein
Participant
Participant

Hello,

 

I have a drawing with a lot of elements, which contain Object Data. This is useful to view/edit in the properties dialog. Disadvantage is that this information (and Xdata)  isn't present in NavisWorks when the DWG is added.

Therefore you need to add Property sets (manage -> Property Set Data). These show the Extended Data tab of the properties dialog. The values can be adjusted there.

To convert the data, I need to select every single element which is time consuming.

 

Does anyone figured out how to add property sets to a drawing and connect these to an element through Lisp?

I'd like to keep this in Lisp, because the rest of my routine is build on Lisp and I don't have Visual Studio installed on my machine (don't have the rights to install it).

The examples I found, run on AutoDesk Architect or AutoDesk MEP, but not on Civil 3D (2019).

 

0 Likes
4,800 Views
16 Replies
Replies (16)
Message 2 of 17

CodeDing
Advisor
Advisor

@gunther.groenestein ,

 

I've never worked w/ property sets yet, so bear with me, Can you pleas epost an example dwg with property sets? Showing how you would like them as your final product.

Also, either in same dwg or another, can you provide objects with the OD properties.

 

This will help us get started.

 

Best,

~DD

0 Likes
Message 3 of 17

gunther.groenestein
Participant
Participant

I added a simple file with Object Data and Property Set.

Message 4 of 17

CodeDing
Advisor
Advisor

@gunther.groenestein ,

 

Well I'm having no luck finding your property set values (at least to the best of my current ability through AutoLISP).

I CAN find the property set 'whatever'. It's located in a dictionary.

But I created this function to help me search deep down in the darkest corners with no luck. I changed one of your property set values from 'Here' to 'Hereiam' (to make it a unique string to search for). and this string can not be found anywhere in the Entity, Dictionaries, REGAPPs, or STYLEs.

(defun c:TEST ( / tabl)
(defun ESFT (ent trace eList txt / eg str x tmp)
(setq eg (entget ent '("*")))
(setq str (strcase (vl-prin1-to-string eg)))
(if (vl-string-search (strcase txt) str)
  (progn (prompt (strcat "\nFOUND... Item: " str)) (exit))
);if
(foreach x eg
  (if (and (eq 'ENAME (type (setq tmp (cdr x))))
	   (not (member tmp eList)))
    (ESFT tmp (cons (strcat (itoa (car x)) "-") trace) (cons tmp eList) txt)
  );if
);foreach
);defun
(ESFT (car (entsel)) '() '() "hereiam") ;<-- search all data within entity
(ESFT (namedobjdict) '() '() "hereiam") ;<-- search all data within dictionaries
;-- search all data within REGAPPs --
(setq tabl (tblnext "APPID" t))
(while tabl
  (ESFT (tblobjname "APPID" (cdr (assoc 2 tabl))) '() '() "hereiam")
  (setq tabl (tblnext "APPID"))
);while
;-- search all data within STYLEs --
(setq tabl (tblnext "STYLE" t))
(while tabl
  (ESFT (tblobjname "STYLE" (cdr (assoc 2 tabl))) '() '() "hereiam")
  (setq tabl (tblnext "STYLE"))
);while
(prompt "Complete.")
(princ)
);defun

It's currently the best I can do.

 

Best,

~DD

0 Likes
Message 5 of 17

gunther.groenestein
Participant
Participant

I found an example code, which is useful for AutoCAD Architect. 

I think I need to know which reference is used in Civil 3D. So I need to replace AecX.AecScheduleApplication.7.9

 

 

(defun C:Testt ()
  (setq ss (ssget))
  (setq i 0)
  (repeat (sslength ss)
    (progn
      (objdata2propset (ssname ss i))
      (setq i (1+ i))
    ) ;_ end of progn
  ) ;_ end of repeat
  (princ)
) ;_ end of defun
 
(defun objdata2propset (ent)
  (setq tblname (car (ade_odgettables ent)))
  (setq str (ade_odgetfield ent (car (ade_odgettables ent)) "FULLNAME" 0))
  (setq vlaObj          (vlax-ename->vla-object ent)
        acadObj         (vlax-get-acad-object)
        schedApp        (vla-getInterfaceObject acadObj "AecX.AecScheduleApplication.7.9") ;_ end of vla-getInterfaceObject
        propSets        (vlax-invoke-method schedApp 'PropertySets vlaObj)
        psdName         "Road Name"
        propSet         (vlax-invoke-method propSets 'Item psdName)
        properties      (vlax-get-property propSet 'Properties)
        propNameValList (reverse (vlax-for prop properties (if (= (vlax-get-property prop 'Name) "Road_Name") (vlax-put-property prop 'Value (vlax-make-variant Str)))))
  ) ;_ end of setq
) ;_ end of defun

 

 

0 Likes
Message 6 of 17

CADaSchtroumpf
Advisor
Advisor

Hi,

I don't know if can help you! I don't have Civil 3d but Map 3d.

I have a code to transfert Object Data to Xdata, it's this that you want?

(defun C:OD2XD ( / LstTable Jeu I iNbJeu Elt EltLstTable iEltLst iNbEltLst EltTable oTableDef sNomTable exdata oLstChamp iChamp
                  iNbChamp nb_rcrds sNomChamp sTypeChamp sValChamp lst_tranfert newent)
	(setq LstTable (ade_odtablelist))
	(setq Jeu (ssget))
	(setq I 0 iNbJeu (sslength JEU))
	(repeat iNbJeu
		(setq Elt (ssname Jeu I))
		(setq I (1+ I))
		(if (setq EltLstTable (ade_odgettables Elt))
			(progn
				(setq iEltLst 0 iNbEltLst (length EltLstTable))
				(repeat iNbEltLst
					(setq EltTable (nth iEltLst EltLstTable))
					(setq iEltLst (1+ iEltLst))
					(setq oTableDef (ade_odtabledefn EltTable))
					(setq sNomTable (cdr (assoc "Tablename" oTableDef)))
					(regapp sNomTable)
					(setq oLstChamp (cdr (assoc "Columns" oTableDef)))
					(setq nb_rcrds (ade_odrecordqty Elt EltTable) lst_tranfert (list sNomTable))
					(repeat nb_rcrds
						(setq iChamp 0 iNbChamp (length oLstChamp))
						(setq nb_rcrds (1- nb_rcrds))
						(repeat iNbChamp
							(setq lst_tranfert
								(cons
									(list
										(cdr (assoc "ColName" (nth iChamp oLstChamp)))
										(cdr (assoc "ColType" (nth iChamp oLstChamp)))
										(ade_odgetfield Elt EltTable (cdr (assoc "ColName" (nth iChamp oLstChamp))) nb_rcrds)
									)
									lst_tranfert
								)
							)
							(setq iChamp (1+ iChamp))
						)
					)
					(setq exdata
						(cons (car (reverse lst_tranfert))
							(mapcar
								'(lambda (x / )
									(cond
										((eq (cadr x) "Real") (cons 1040 (caddr x)))
										((eq (cadr x) "Integer") (cons 1070 (caddr x)))
										((eq (cadr x) "Point") (cons 1010 (caddr x)))
										((eq (cadr x) "Character") (cons 1000 (caddr x)))
									)
								)
								(cdr (reverse lst_tranfert))
							)
						)
					)
					(setq exdata (list (list -3 exdata)))
					(setq newent (append (entget Elt) exdata))
					(entmod newent)
				)
			)
		)
	)
	(prin1)
)
0 Likes
Message 7 of 17

gunther.groenestein
Participant
Participant

Hello CADaSchtroumpf ,

 

It is a nice tool, but for my case I need to fill the extended data. Besides the "classic" geometry you can add Objectdata, Xdata and Extended Data to elements. I don't know why these different data can be added. One should be enough...

Well. The Extended Data can be found in the Properties Palette. These can be added through Manage -> Define Property Sets.

I need to find the correct ActiveX component or DLL to connect and use the properties. I'm not able to use .NET to solve the problem (though I have .NET experience). Also Dynamo Script isn't an option, because it cannot be added behind a simple menu item or button.

 

0 Likes
Message 8 of 17

CADaSchtroumpf
Advisor
Advisor

@gunther.groenestein  a écrit :

Hello CADaSchtroumpf ,

 

It is a nice tool,

...

 The Extended Data can be found in the Properties Palette. These can be added through Manage -> Define Property Sets.

Thank's

I don't have Extended Data in Map3D, I can't help you, sorry.

0 Likes
Message 9 of 17

АлексЮстасу
Advisor
Advisor

Hi, Denon,


@CodeDing wrote:

I CAN find the property set 'whatever'. It's located in a dictionary.


We tried to get rid of the problem of many different data - PropertySets, Object Data, Xdata, Xrecord.
And we made a "copy" of Object Data in Xrecord. ODEMUDATA dictionary. (I 'm not a programmer, and I can be wrong).
Can such data from Xrecord be managed using Lisp?
For example, convert them to Xdata, csv, and back?

 


-- Alexander, private person, pacifist, english only with translator 🙂 --

Object-modeling _ odclass-odedit.com _ Help

Message 10 of 17

gunther.groenestein
Participant
Participant

Well. The transfer to Xdata is nice to do, but to view this in NavisWorks I need to use the Property Sets. It is a shame that this isn't available to create these property sets through Lisp like Xdata, Xrecord or object data.

If NavisWorks is able to read all the extra datasources in a DWG, it wasn't an issue.

Now we need to search and make workarounds to get it done.

0 Likes
Message 11 of 17

In my opinion, it is very amazing - Property Sets exist in Architecture, MEP for a very long time. Years, probably, 20 or more? But they do not have an import from Xdata, from csv, exports. In Civil they are added in 2013, updated in 2016.

And no one has created their export/import in all this time?

 


-- Alexander, private person, pacifist, english only with translator 🙂 --

Object-modeling _ odclass-odedit.com _ Help

0 Likes
Message 12 of 17


@gunther.groenestein wrote:

... but to view this in NavisWorks I need to use the Property Sets.

If NavisWorks is able to read all the extra datasources in a DWG, it wasn't an issue.

Now we need to search and make workarounds to get it done.


I 'm trying to at least gradually find these ways. It would be better, of course, to go straight, but I 'm not a programmer or rich.
For example, recently CADaSchtroumpf Lisp created export/import OD/csv - see applications.

Maybe somehow transfer data through csv?

 

CodeDing,

Thanks for like. But is it possible on Lisp to manage data from Xrecord - as in the previous XR_sample.dwg?
For example, convert them to Xdata, csv, and back?

 


-- Alexander, private person, pacifist, english only with translator 🙂 --

Object-modeling _ odclass-odedit.com _ Help

0 Likes
Message 13 of 17

CodeDing
Advisor
Advisor

@АлексЮстасу ,

 

Yes it is possible, however you have a lot of code and it's a bit chaotic to go through. I understand what's happening, but it seems as if it was done without organization in mind.

 

Can you maybe post an example of some raw data? What data are you placing in your dictionary? This will help us determine a good approach for the data. 

 

Also, unless OP wants this information also, please respond to me with a direct message and I can help when I get time. That way we are not using this thread for an unintended purpose.

 

Best,

~DD

Message 14 of 17

Sea-Haven
Mentor
Mentor

If you have the Aecx.dll this is from Architecture then it may be possible to open/create the property set, using 

(setq schedApp (vla-getInterfaceObject (vlax-get-acad-object)  "AecX.AecScheduleApplicationx.x")) ; change x.x.
(setq propSets (vlax-invoke-method schedApp 'PropertySets vlaObj)

 

But this dll does not exist in CIV3D/MAP so it may be another Dll is to be used.

 

This is a line with property set exposed using "Properties"

 

screenshot174.png

 

 

 

0 Likes
Message 15 of 17

АлексЮстасу
Advisor
Advisor

Perhaps in the Civil for this AecPropDataMgd.dll. But that 's not certain, I 'm not a programmer at all.
I see your Property Sets in Civil in the Properties window as in your picture.

 


-- Alexander, private person, pacifist, english only with translator 🙂 --

Object-modeling _ odclass-odedit.com _ Help

0 Likes
Message 16 of 17

gunther.groenestein
Participant
Participant

Should it be a decent solution to provide this AECX.dll file to the Civil 3D/Map 3D users? In that case we can optimize our workprocess instead of looking for a solution in .NET (or other languages).

AutoDesk has that file...

0 Likes
Message 17 of 17

Sea-Haven
Mentor
Mentor

May have to look at getting a copy to see what happens. I was thinking of downloading Visual Studio and try to find. Did find some other stuff that exposes the dictionary but got stuck going deeper.

0 Likes